I have a pet peeve when it comes to Java-based text processing systems:
I always take a look
at whether text nodes use String or char[] to store the text of the text
node. Usually they use String - and it's wrong because when it's output
through the Writer, the Writer will call getChars() on the String to obtain
a char[] and then write out the char[]. If the node stored char[] instead of
String in its text node, we would avoid the performance penalty of executing
Writer.write(String) instead of Writer.write(char[]) - which is an
additional "System.arraycopy()" (as well as a "new char[]" if
String.length()>1024).
Altough this is a small and trivial optimization, it comes at no cost and
spares both time and memory which can make a difference in throughput of a
heavy-loaded environment.
Attached is a diff -u patch for
org.apache.velocity.runtime.parser.node.ASTText that switches its internal
storage from String to char[].
Attila.
>
ASTText.java.patch