Benefit from computing String Hash at compile time?
Ulf.Zibis at gmx.de
Wed Jan 6 11:05:15 PST 2010
Am 06.01.2010 10:19, Fredrik Öhrström schrieb:
> Thus the generated string switch bytecode should
> be as easy to detect and rip out as possible. (Which was the reason for
> my previous gripe where I wanted a simpler pattern, but I forgot about
> the low end JVMs.) Computing the hash at runtime would make the pattern
> worse and gain nothing since the hash is indeed specified in the
The computation of the hashes should only be done once on the first run
through a string switch statement, even on low end JVMs. After each
String object caches its own hash, so could be used for n more runs.
Additionally all String constants provide natively computed hashes
automatically, as they are always interned, and the equals method could
benefit from Bug Id: 6912520
<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6912520>, not only
for the string switch construct.
More information about the coin-dev