RFR: 8336274: MutableBigInteger.leftShift(int) optimization [v4]

Raffaello Giulietti rgiulietti at openjdk.org
Mon Sep 2 16:07:22 UTC 2024


On Sun, 1 Sep 2024 16:32:00 GMT, fabioromano1 <duke at openjdk.org> wrote:

>> This implementation of MutableBigInteger.leftShift(int) optimizes the current version, avoiding unnecessary copy of the MutableBigInteger's value content and performing the primitive shifting only in the original portion of the value array rather than in the value yet extended with trailing zeros.
>
> fabioromano1 has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Code more clear

Here are a couple of preliminary work that can be done before delving into the details:
* If nothing else speaks against, new tests should use a testing framework, preferably [JUnit 5](https://junit.org/junit5/).
* In the OpenJDK we use [jtreg](https://openjdk.org/jtreg/) to run tests. This requires adding a few structured comment lines before the class declaration. For an example, see [ByteArrayConstructorTest](https://github.com/openjdk/jdk/blob/master/test/jdk/java/math/BigInteger/ByteArrayConstructorTest.java).
(See [jtreg tags](https://openjdk.org/jtreg/tag-spec.html) for full documentation.)
* I wonder if `MutableBigIntegerBox` can be reduced to just a set of accessors for the `MutableBigInteger` fields. Also, I guess that the benchmarks can be written to use the public class `BigInteger` to avoid having two copies of `MutableBigIntegerBox`.
* This PR is open since a couple of months now, so it would be a good thing to merge the branch `master` into the PR's branch.

Thanks

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

PR Comment: https://git.openjdk.org/jdk/pull/20008#issuecomment-2325038239


More information about the core-libs-dev mailing list