[cp-patches] RFC: changes to java.lang.Integer, Long...

Ian Rogers rogers.email at gmail.com
Tue Jun 3 13:21:51 UTC 2008


Andrew Haley wrote:
> Ian Rogers wrote:
>
>   
>> please give your comments on the attached patch. It tries to reduce the
>> size of char[] for strings used to hold numbers. It changes Float/Double
>> equals to use bit based comparisons rather than division. It increases
>> the use of valueOf methods. It adds a cache of values from -128 to 127
>> for Long. It adds a cache of the values of zero and one to Float and
>> Double.
>>
>> The string size is an estimate. For decimal numbers it will divide the
>> value repeatedly by 8, causing the string length to be over estimated by
>> a character for values like 999. This string size is still better than
>> the current estimate of 33 characters. It also avoids the use of
>> division (shifts are used) and/or lookup tables.
>>     
>
> I am really not convinced by the cache of values from -128 to 127.  It's
> a significant overhead for the startup time, and I find it hard to imagine
> a justification for it.
>
> Andrew.
>   
Sorry, I replied to this off-list accidentally. One alternative is to 
move the class initialization into an inner class by placing the cache 
in an inner class. That way the cache is only built when valueOf a 
cached value is called. This approach would prompt similar changes in 
the other Number valueOf methods.

Ian
--
http://www.cs.man.ac.uk/~irogers/



More information about the Classpath-patches mailing list