xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.Pietschmann" <j3322...@yahoo.de>
Subject Re: String.intern() thoughts
Date Mon, 01 Dec 2003 21:40:40 GMT
Glen Mazza wrote:
> No need-the "gotcha" site you gave earlier did give
> some specific drawbacks under string compares:  
> http://mindprod.com/jgloss/gotchas.html#COMPARISON

That's not a drawback. Interned strings allow comparision of
   String a="a".intern();
   String b="a".intern();
   if(a==b) { System.out.println("equal"); }
With non-interned strings you need a.equals(b), which
may be slower, for longer strings anyway.

Same for the time needed for interning: I doubt a home
grown mechanism for this, which is exactly what Austin
proposes, would be more efficient.

The most important gotcha is that interned strings may lock
up memory forever. If interning is done only for property
names and enumeration tokens (in contrast to property values),
this may be acceptable.


View raw message