From 3e515ef90f1018adbc3a91981ab81a4e783d16d1 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 3 Nov 2009 15:01:50 -0800 Subject: [PATCH] 6897550: BigInteger constructor should use local cached String length Reviewed-by: andrew, chegar --- jdk/src/share/classes/java/math/BigInteger.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/math/BigInteger.java b/jdk/src/share/classes/java/math/BigInteger.java index a00c6633fc5..d7d4f19f040 100644 --- a/jdk/src/share/classes/java/math/BigInteger.java +++ b/jdk/src/share/classes/java/math/BigInteger.java @@ -288,11 +288,11 @@ public class BigInteger extends Number implements Comparable { */ public BigInteger(String val, int radix) { int cursor = 0, numDigits; - int len = val.length(); + final int len = val.length(); if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) throw new NumberFormatException("Radix out of range"); - if (val.length() == 0) + if (len == 0) throw new NumberFormatException("Zero length BigInteger"); // Check for at most one leading sign @@ -303,7 +303,7 @@ public class BigInteger extends Number implements Comparable { // No leading sign character or at most one leading sign character if (index1 == 0 || index2 == 0) { cursor = 1; - if (val.length() == 1) + if (len == 1) throw new NumberFormatException("Zero length BigInteger"); } if (index1 == 0) @@ -342,7 +342,7 @@ public class BigInteger extends Number implements Comparable { // Process remaining digit groups int superRadix = intRadix[radix]; int groupVal = 0; - while (cursor < val.length()) { + while (cursor < len) { group = val.substring(cursor, cursor += digitsPerInt[radix]); groupVal = Integer.parseInt(group, radix); if (groupVal < 0)