On Thu, 01 Mar 2012 12:01:46 +0100, Kirk Pepperdine
<[email protected]> wrote:
On the question of Strings, StringBuffer/Builder and copying char
arrays. Sorry to say that this is still a huge performance drain in many
applications. It's the only place where I miss c pointers ;-). Hotspot
rarely does the right thing when it comes to string and string
manipulation. It's javac that makes the biggest impact (string1 +
string2 is converted to using StringBuilder and so on). So here are a
few rules when working with strings.
Rule #1, don't copy them or force them to copy themselves.
Rule #2, use a flyweight instead of a copy
Rule #3, don't copy them or force them to copy themselves.
Rule #4, use System.arraycopy, it is the most efficient way to copy a
primitive array.
Perhaps does this explain why e.g. Perl is still faster than Java in some
heavy text manipulation benchmarks? (not my direct experience, I'm not
using Perl since a lot of time, this assertion just came up a few weeks
ago in a JUG discussion out of a reputable commenter).
--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
[email protected]
http://tidalwave.it - http://fabriziogiudici.it
--
You received this message because you are subscribed to the Google Groups "The Java
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.