Skip to content

Commit

Permalink
[libc][NFC] Simplify BigInt::mul (#84468)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchatelet committed Mar 8, 2024
1 parent 7457e2c commit 9baa414
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions libc/src/__support/UInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,13 @@ struct BigInt {
// Returns the carry value produced by the multiplication operation.
LIBC_INLINE constexpr WordType mul(WordType x) {
BigInt<2 * WORD_SIZE, Signed, WordType> partial_sum(0);
WordType carry = 0;
for (size_t i = 0; i < WORD_COUNT; ++i) {
NumberPair<WordType> prod = full_mul(val[i], x);
BigInt<2 * WORD_SIZE, Signed, WordType> tmp({prod.lo, prod.hi});
carry += partial_sum.add(tmp);
const WordType carry = partial_sum.add(tmp);
val[i] = partial_sum.val[0];
partial_sum.val[0] = partial_sum.val[1];
partial_sum.val[1] = carry;
carry = 0;
}
return partial_sum.val[1];
}
Expand Down

0 comments on commit 9baa414

Please sign in to comment.