[jdom-interest] question about running speed

Alex Rosen arosen at silverstream.com
Thu Apr 11 07:50:14 PDT 2002


> As for us, we'll be trying to fix the StringBuffer.copy() bottleneck we
> see in JDK 1.2, but it looks like JDK 1.4 may not share the same
> underlying implementation, so for JDK 1.4 users this work won't matter
> at all.  Who knows about non-JDK execution.  Oh the fun.

I did a couple of tests last night. Since the common case is that SAXHandler
only gets called once per text section, I tried optimizing for that. When
the first text chunk comes in, it creates a String from the given char
array. In the common case where that's the only text chunk before
flushCharacters() occurs, then we've done the absolute minimal work
necessary, so it can't get any faster or memory-efficient than that. If we
then get a second text chunk, we switch over to using a StringBuffer
instead. It turns out that this doesn't cost us too much. Plus, it's JDK 1.1
compatible. Does this sound like a reasonable strategy? I can't think of any
drawbacks. I'll try a few more tests and then send in a patch sometime soon.

Alex




More information about the jdom-interest mailing list