RFR: JDK-8277175 : Add a parallel multiply method to BigInteger [v5]
Paul Sandoz
psandoz at openjdk.java.net
Thu Dec 16 01:05:01 UTC 2021
On Wed, 15 Dec 2021 14:31:26 GMT, kabutz <duke at openjdk.java.net> wrote:
>> src/java.base/share/classes/java/math/BigInteger.java line 2000:
>>
>>> 1998: da1 = a2.add(a0);
>>> 1999: db1 = b2.add(b0);
>>> 2000: var vm1_task = RecursiveOp.multiply(da1.subtract(a1), db1.subtract(b1), parallel, depth + 1);
>>
>> I recommend incrementing the depth in the `RecursiveOp` constructor, thereby reducing the repetition.
>
> Inside the constructor would not work, since we do not construct RecursiveOp for all the tasks. However, I have incremented the parameter depth. I don't like changing parameters inside methods, but since I'm doing it where it is being used, I feel that the code is now better than before. Thanks for the suggestion.
I am confused by "we do not construct RecursiveOp for all the tasks", since each call to `RecursiveOp.multiply/square` constructs a new object that is an instance of `RecursiveOp`.
Your approach looks good.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6409
More information about the core-libs-dev
mailing list