Skip to content

Commit b91e6f7

Browse files
authored
Merge pull request #407 from DaniPopes/add-bitwise-ops
perf: use bitwise operations in add/sub impls
2 parents 52e4351 + 45eab6b commit b91e6f7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/add.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
6161
const fn u64_carrying_add(lhs: u64, rhs: u64, carry: bool) -> (u64, bool) {
6262
let (a, b) = lhs.overflowing_add(rhs);
6363
let (c, d) = a.overflowing_add(carry as u64);
64-
(c, b || d)
64+
(c, b | d)
6565
}
6666

6767
if BITS == 0 {
@@ -103,7 +103,7 @@ impl<const BITS: usize, const LIMBS: usize> Uint<BITS, LIMBS> {
103103
const fn u64_borrowing_sub(lhs: u64, rhs: u64, borrow: bool) -> (u64, bool) {
104104
let (a, b) = lhs.overflowing_sub(rhs);
105105
let (c, d) = a.overflowing_sub(borrow as u64);
106-
(c, b || d)
106+
(c, b | d)
107107
}
108108

109109
if BITS == 0 {

0 commit comments

Comments
 (0)