Vincent Hennebert wrote:
> Hi,
> 
> Manuel Mall a écrit :
>> On Wednesday 18 July 2007 02:58, Andreas L Delmelle wrote:
> <snip/>
>> Interestingly Java 1.5 has added the Integer.valueOf(int) method with 
>> the following comment:
> 
> Flyweight pattern. That's what I was looking for before replying to
> Andreas' commit, and I was surprised to not find it in the 1.4 standard
> library. A good thing it finally got added.
> 
> 
>> Returns a Integer instance representing the specified int value. If a 
>> new Integer instance is not required, this method should generally be 
>> used in preference to the constructor Integer(int), as this method is 
>> likely to yield significantly better space and time performance by 
>> caching frequently requested values.
>>
>> Obviously we can't use it because of backwards compatibility with 1.4 
>> but it seems to address, to some extent, the performance issue you 
>> tried to solve.
> 
> Indeed. And with the auto-boxing of primitive types we wouldn't even see
> those ugly new Integer(...) anymore. And guess what? The compiler makes
> use of Integer.valueOf() for auto-boxing.
> 
> Shall we launch a poll on fop-user about abandoning support for 1.4 and
> require 1.5 as a minimum? :-]

Ho, ho.

alt-design always cached _all_ the Integer instances it needed. Another
startling new idea. As Manuel points out, unnecessary in 1.5+, unless
you are using a lot of Integers outside the range -128<=x<=127

-- 
Peter B. West <http://cv.pbw.id.au/>
Folio <http://defoe.sourceforge.net/folio/>

Reply via email to