@@ -33,18 +33,11 @@ public static BigDecimal parse(String valueStr) {
3333 }
3434
3535 public static BigDecimal parse (char [] chars , int off , int len ) {
36- if (off > 0 || len != chars .length ) {
37- chars = Arrays .copyOfRange (chars , off , off +len );
38- }
39- return parse (chars );
40- }
41-
42- public static BigDecimal parse (char [] chars ) {
43- final int len = chars .length ;
4436 try {
4537 if (len < 500 ) {
46- return new BigDecimal (chars );
38+ return new BigDecimal (chars , off , len );
4739 }
40+ chars = Arrays .copyOfRange (chars , off , off +len );
4841 return new BigDecimalParser (chars ).parseBigDecimal (len / 10 );
4942 } catch (NumberFormatException e ) {
5043 String desc = e .getMessage ();
@@ -53,17 +46,21 @@ public static BigDecimal parse(char[] chars) {
5346 desc = "Not a valid number representation" ;
5447 }
5548 String stringToReport ;
56- if (chars . length <= MAX_CHARS_TO_REPORT ) {
57- stringToReport = new String (chars );
49+ if (len <= MAX_CHARS_TO_REPORT ) {
50+ stringToReport = new String (chars , off , len );
5851 } else {
59- stringToReport = new String (Arrays .copyOfRange (chars , 0 , MAX_CHARS_TO_REPORT ))
52+ stringToReport = new String (Arrays .copyOfRange (chars , off , MAX_CHARS_TO_REPORT ))
6053 + "(truncated, full length is " + chars .length + " chars)" ;
6154 }
6255 throw new NumberFormatException ("Value \" " + stringToReport
6356 + "\" can not be represented as `java.math.BigDecimal`, reason: " + desc );
6457 }
6558 }
6659
60+ public static BigDecimal parse (char [] chars ) {
61+ return parse (chars , 0 , chars .length );
62+ }
63+
6764 private BigDecimal parseBigDecimal (final int splitLen ) {
6865 boolean numHasSign = false ;
6966 boolean expHasSign = false ;
0 commit comments