Unverified Commit bc175b63 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: use match consistently in macro (#86767)

### What?

Cleanup for consistency
parent 6ef90ef4
...@@ -1055,22 +1055,25 @@ macro_rules! update { ...@@ -1055,22 +1055,25 @@ macro_rules! update {
} }
macro_rules! update_count { macro_rules! update_count {
($task:ident, $key:ident $input:tt, -$update:expr) => {{ ($task:ident, $key:ident $input:tt, -$update:expr) => {
let update = $update; match $update {
let mut state_change = false; update => {
$crate::backend::storage::update!($task, $key $input, |old: Option<_>| { let mut state_change = false;
#[allow(unused_comparisons, reason = "type of update might be unsigned, where update < 0 is always false")] $crate::backend::storage::update!($task, $key $input, |old: Option<_>| {
if let Some(old) = old { #[allow(unused_comparisons, reason = "type of update might be unsigned, where update < 0 is always false")]
let new = old - update; if let Some(old) = old {
state_change = old <= 0 && new > 0 || old > 0 && new <= 0; let new = old - update;
(new != 0).then_some(new) state_change = old <= 0 && new > 0 || old > 0 && new <= 0;
} else { (new != 0).then_some(new)
state_change = update < 0; } else {
(update != 0).then_some(-update) state_change = update < 0;
(update != 0).then_some(-update)
}
});
state_change
} }
}); }
state_change };
}};
($task:ident, $key:ident $input:tt, $update:expr) => { ($task:ident, $key:ident $input:tt, $update:expr) => {
match $update { match $update {
update => { update => {
...@@ -1091,22 +1094,26 @@ macro_rules! update_count { ...@@ -1091,22 +1094,26 @@ macro_rules! update_count {
}; };
($task:ident, $key:ident, -$update:expr) => { ($task:ident, $key:ident, -$update:expr) => {
$crate::backend::storage::update_count!($task, $key {}, -$update) $crate::backend::storage::update_count!($task, $key {}, -$update)
}; ($task:ident, $key:ident, $update:expr) => { };
($task:ident, $key:ident, $update:expr) => {
$crate::backend::storage::update_count!($task, $key {}, $update) $crate::backend::storage::update_count!($task, $key {}, $update)
}; };
} }
macro_rules! update_count_and_get { macro_rules! update_count_and_get {
($task:ident, $key:ident $input:tt, -$update:expr) => {{ ($task:ident, $key:ident $input:tt, -$update:expr) => {
let update = $update; match $update {
let mut new = 0; update => {
$crate::backend::storage::update!($task, $key $input, |old: Option<_>| { let mut new = 0;
let old = old.unwrap_or(0); $crate::backend::storage::update!($task, $key $input, |old: Option<_>| {
new = old - update; let old = old.unwrap_or(0);
(new != 0).then_some(new) new = old - update;
}); (new != 0).then_some(new)
new });
}}; new
}
}
};
($task:ident, $key:ident $input:tt, $update:expr) => { ($task:ident, $key:ident $input:tt, $update:expr) => {
match $update { match $update {
update => { update => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment