Skip to content

Commit

Permalink
Avoid evaluating $c more than once in overflow macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 31, 2021
1 parent 5d2cbcd commit 18a88da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ impl<'a> Deserializer<read::StrRead<'a>> {

macro_rules! overflow {
($a:ident * 10 + $b:ident, $c:expr) => {
$a >= $c / 10 && ($a > $c / 10 || $b > $c % 10)
match $c {
c => $a >= c / 10 && ($a > c / 10 || $b > c % 10),
}
};
}

Expand Down

0 comments on commit 18a88da

Please sign in to comment.