<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-CH" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US">I can confirm that testing that condition is indeed useless<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Andrey Turbanov <turbanoff@gmail.com><br>
<b>Date: </b>Friday, 2022-November-25 at 14:18<br>
<b>To: </b>core-libs-dev <core-libs-dev@openjdk.java.net><br>
<b>Subject: </b>Redundant condition in java.math.MutableBigInteger#divideMagnitude<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:11.0pt">Hello.<br>
I noticed that IntelliJ IDEA show warning in the method<br>
java.math.MutableBigInteger#divideMagnitude<br>
here - <a href="https://github.com/openjdk/jdk/blob/4f65570204e2d38415e7761bd81660b081eae882/src/java.base/share/classes/java/math/MutableBigInteger.java#L1536">
https://github.com/openjdk/jdk/blob/4f65570204e2d38415e7761bd81660b081eae882/src/java.base/share/classes/java/math/MutableBigInteger.java#L1536</a><br>
It seems that condition is always 'true'<br>
<br>
   if (rem.intLen == nlen) {<br>
<br>
'rem' and 'nlen' variables are not changed anyhow after this<br>
assignment a few lines above:<br>
<br>
    int nlen = rem.intLen;<br>
<br>
To make sure that it's really true, I've modified source to include else branch:<br>
<br>
} else {<br>
    throw new AssertionError("Condition 'rem.intLen == nlen' wasn't met.");<br>
}<br>
<br>
And all tests from "jdk/java/math" passed.<br>
<br>
<br>
Can we clean up the code to remove this condition? Code is already<br>
complex enough and each condition makes its reading harder.<br>
It was added as part of performance improvements in<br>
<a href="https://bugs.openjdk.org/browse/JDK-7082971">https://bugs.openjdk.org/browse/JDK-7082971</a><br>
<br>
<br>
Andrey Turbanov<o:p></o:p></span></p>
</div>
</div>
</body>
</html>