Skip to content

Commit 9fb6696

Browse files
committed
replace | with || in {unsigned_int}::borrowing_sub
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 sbb eax, esi setb dl ret ```
1 parent 5913ef6 commit 9fb6696

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/core/src/num/uint_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ macro_rules! uint_impl {
16061606
// to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic
16071607
let (a, b) = self.overflowing_sub(rhs);
16081608
let (c, d) = a.overflowing_sub(borrow as $SelfT);
1609-
(c, b | d)
1609+
(c, b || d)
16101610
}
16111611

16121612
/// Computes the absolute difference between `self` and `other`.

0 commit comments

Comments
 (0)