RFR: 8281259: MutableBigInteger subtraction could be simplified

Daniel Jeliński djelinski at openjdk.java.net
Fri Feb 4 10:25:44 UTC 2022


The proposed form of borrow bit handling is [already used in BigInteger class](https://github.com/djelinski/jdk/blob/ce26a19be5e907c11164b46f1bcb370b534d5bf6/src/java.base/share/classes/java/math/BigInteger.java#L1558).

JMH results without the patch:

Benchmark            (maxNumbits)  Mode  Cnt        Score        Error  Units
BigIntegers.testGcd           256  avgt   25  3181205,367 ± 155272,427  ns/op

JMH results with the patch applied:

Benchmark            (maxNumbits)  Mode  Cnt        Score       Error  Units
BigIntegers.testGcd           256  avgt   25  2696030,849 ± 14141,940  ns/op

-------------

Commit messages:
 - Remove unnecessary looping
 - Simplify borrow bit handling
 - Add gcd microbenchmark

Changes: https://git.openjdk.java.net/jdk/pull/7342/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7342&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8281259
  Stats: 16 lines in 2 files changed: 11 ins; 0 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7342.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7342/head:pull/7342

PR: https://git.openjdk.java.net/jdk/pull/7342


More information about the core-libs-dev mailing list