Salikh,
I wonder why such an elegant solution haven't been made before?

The benefit of String.intern I know:
1) Fast comparison (May be we can speedup some internal algorithms like
reflection this way?)
2) Low memory consumption if there are a lot of duplicates

The overhead:
1) AFAIK every access to the weakmap must be synchronized.



On 7/28/06, Salikh Zakirov <[EMAIL PROTECTED]> wrote:

Salikh Zakirov wrote:
>> Subject: [PATCH] Pure java string intern()

I have just been privately asked by a fellow colleague
what the interning is used for.
So I figured it would be nice to describe the answer on the list
too, especially because I am interested in learning something new
on the subject :)

The most important reason I know is that interning
is required by the specification.

A particular use case I know is message localization: having string
literals interned by default allows to optimize the lookup
in the message bundles, as we can intern the keys on loading
the bundle, and use object reference comparison later at lookup time.

While I was working on the patch, there was a moment when I screwed
the condition in intern() function, and it worked incorrectly,
and returned incorrect strings sometimes. When I tried to run
Eclipse with the bug, it complained about missing localization
string and terminated by exception.

Any other insights?


---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Mikhail Fursov

Reply via email to