RFR [9] 8041972: Add improved parse/format methods for Long/Integer

Remi Forax forax at univ-mlv.fr
Sun Jun 15 11:48:49 UTC 2014


On 06/15/2014 12:36 AM, Claes Redestad wrote:
> Hi,
>
> please review this patch to add offset based variants of 
> Integer.parseInt/parseUnsignedInt, Long.parseLong/parseUnsignedLong 
> and expose them through JavaLangAccess along with 
> formatUnsignedInt/-Long. This is proposed to enable a number of minor 
> optimizations, starting with 
> https://bugs.openjdk.java.net/browse/JDK-8006627
>
> Webrev: http://cr.openjdk.java.net/~redestad/8041972/webrev.0/
>
> Thanks!
>
> /Claes

In my opinion, and as suggested in the description of 8041972, these 
methods should be public.
Having written my share of scanners/parsers in Java, these methods are 
really helpful but
given that they only rely on charAt/length of String, I think they 
should take a CharSequence and not a String as first parameter,
in order to support other storages of characters like by example a 
java.nio.CharBuffer.

So for me, instead of adding a bunch of method in shared secrets, those 
method should be public and take a CharSequence.

Miinor nits, Integer.parseInt(String,int,int) don't need to test if s is 
null given it delegated to parseInt(String, int, int, int),
and Integer.parseInt(String) should directly call parseInt(s, 10, 0, 
s.length()) instead of calling parseInt(s, 10) that calls
parseInt(s, 10, 0) that calls parseInt(s, 10, 0, s.length()).

cheers,
Rémi




More information about the core-libs-dev mailing list