RFR: JDK-8297731: Remove redundant check in MutableBigInteger.divide
Joe Darcy
darcy at openjdk.org
Tue Nov 29 20:25:21 UTC 2022
On Tue, 29 Nov 2022 07:39:59 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
> IDEA now highlights unnecessary `rem.offset=1` assignments, which are above modified code. Now we always overwrite it with `0` anyway.
>
> https://github.com/openjdk/jdk/blob/6f06f440bcf8a5db379b80e8765af38a15449356/src/java.base/share/classes/java/math/MutableBigInteger.java#L1498
>
> https://github.com/openjdk/jdk/blob/6f06f440bcf8a5db379b80e8765af38a15449356/src/java.base/share/classes/java/math/MutableBigInteger.java#L1504
>
> https://github.com/openjdk/jdk/blob/6f06f440bcf8a5db379b80e8765af38a15449356/src/java.base/share/classes/java/math/MutableBigInteger.java#L1520
>
> Perhaps we can drop them too.
Hmm. Looks to me like the earlier assignments of 1 to the rem object's offset field are to preserve inter-field semantic constraints. So while it is true this field is not used before it is overwritten circa line 1536, I'd reluctant to "break" the object constraints in the interim since it could complicated future maintenance, event with commenting.
Thoughts @bplb or @rgiulietti ?
-------------
PR: https://git.openjdk.org/jdk/pull/11395
More information about the core-libs-dev
mailing list