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 {
}
macro_rules! update_count {
($task:ident, $key:ident $input:tt, -$update:expr) => {{
let update = $update;
let mut state_change = false;
$crate::backend::storage::update!($task, $key $input, |old: Option<_>| {
#[allow(unused_comparisons, reason = "type of update might be unsigned, where update < 0 is always false")]
if let Some(old) = old {
let new = old - update;
state_change = old <= 0 && new > 0 || old > 0 && new <= 0;
(new != 0).then_some(new)
} else {
state_change = update < 0;
(update != 0).then_some(-update)
($task:ident, $key:ident $input:tt, -$update:expr) => {
match $update {
update => {
let mut state_change = false;
$crate::backend::storage::update!($task, $key $input, |old: Option<_>| {
#[allow(unused_comparisons, reason = "type of update might be unsigned, where update < 0 is always false")]
if let Some(old) = old {
let new = old - update;
state_change = old <= 0 && new > 0 || old > 0 && new <= 0;
(new != 0).then_some(new)
} else {
state_change = update < 0;
(update != 0).then_some(-update)
}
});
state_change
}
});
state_change
}};
}
};
($task:ident, $key:ident $input:tt, $update:expr) => {
match $update {
update => {
......@@ -1091,22 +1094,26 @@ macro_rules! update_count {
};
($task:ident, $key:ident, -$update:expr) => {
$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)
};
}
macro_rules! update_count_and_get {
($task:ident, $key:ident $input:tt, -$update:expr) => {{
let update = $update;
let mut new = 0;
$crate::backend::storage::update!($task, $key $input, |old: Option<_>| {
let old = old.unwrap_or(0);
new = old - update;
(new != 0).then_some(new)
});
new
}};
($task:ident, $key:ident $input:tt, -$update:expr) => {
match $update {
update => {
let mut new = 0;
$crate::backend::storage::update!($task, $key $input, |old: Option<_>| {
let old = old.unwrap_or(0);
new = old - update;
(new != 0).then_some(new)
});
new
}
}
};
($task:ident, $key:ident $input:tt, $update:expr) => {
match $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