Skip to content

Commit 5913ef6

Browse files
committed
replace | with || in {unsigned_int}::carrying_add
Using short-circuiting operators makes it easier to perform some kinds of source code analysis, like MC/DC code coverage (a requirement in safety-critical environments). The optimized x86_64 assembly is the same between the old and new versions: ``` mov eax, edi add dl, -1 adc eax, esi setb dl ret ```
1 parent 47aeac6 commit 5913ef6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/num/uint_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ macro_rules! uint_impl {
15251525
// to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic
15261526
let (a, b) = self.overflowing_add(rhs);
15271527
let (c, d) = a.overflowing_add(carry as $SelfT);
1528-
(c, b | d)
1528+
(c, b || d)
15291529
}
15301530

15311531
/// Calculates `self` + `rhs` with a signed `rhs`

0 commit comments

Comments
 (0)