< prev index next >

src/java.base/share/classes/java/math/BigInteger.java

Print this page
rev 16194 : imported patch XXXXXXX-Use-StringBuilder-appendN-method

@@ -3889,13 +3889,11 @@
 
         // Append remaining digit groups padded with leading zeros
         for (int i=numGroups-2; i >= 0; i--) {
             // Prepend (any) leading zeros for this digit group
             int numLeadingZeros = digitsPerLong[radix]-digitGroup[i].length();
-            if (numLeadingZeros != 0) {
-                buf.append(zeros[numLeadingZeros]);
-            }
+            buf.appendN('0', numLeadingZeros);
             buf.append(digitGroup[i]);
         }
         return buf.toString();
     }
 

@@ -3920,13 +3918,11 @@
             String s = u.smallToString(radix);
 
             // Pad with internal zeros if necessary.
             // Don't pad if we're at the beginning of the string.
             if ((s.length() < digits) && (sb.length() > 0)) {
-                for (int i=s.length(); i < digits; i++) {
-                    sb.append('0');
-                }
+                sb.appendN('0', digits - s.length());
             }
 
             sb.append(s);
             return;
         }

@@ -3975,19 +3971,10 @@
             powerCache = pc; // volatile write, publish
         }
         return cacheLine[exponent];
     }
 
-    /* zero[i] is a string of i consecutive zeros. */
-    private static String zeros[] = new String[64];
-    static {
-        zeros[63] =
-            "000000000000000000000000000000000000000000000000000000000000000";
-        for (int i=0; i < 63; i++)
-            zeros[i] = zeros[63].substring(0, i);
-    }
-
     /**
      * Returns the decimal String representation of this BigInteger.
      * The digit-to-character mapping provided by
      * {@code Character.forDigit} is used, and a minus sign is
      * prepended if appropriate.  (This representation is compatible
< prev index next >