Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] indexOf O(1) patch?

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] indexOf O(1) patch?
  • Date: Tue, 01 Feb 2005 23:55:13 -0500

Wolfgang Hoschek wrote:


Except that String.intern() is not the way to go, as outlined in a mail some months ago (it's very slow, and can cause memory leaks if you're unlucky). One should better have a string pool per document, or similar. So the CVS update from a few minutes ago is highly problematic, IMHO.

I've actually been able to pull about half of that back out. It occurred to me that the parser was already interning the local names (but not the prefixes). Therefore I could just have the parser pass the local name and the qualified name to the build methods. That way I don't have to extract the local name from the qualified name and then intern it.

Note that the parser was already doing the work of finding and interning the local name. XOM was simply ignoring that. Now it's not. It's a little ugly, and feels strange to be passing the same information in twice, once in the qualifiedName and once in the localName, but that's just how SAX is. It's all completely hidden in the non-public parts so we can twiddle with this or try more complex schemes like a document wide prefix cache if there prove to be performance issues.

On other note: prefixes are now only interned if they're non-empty, so that eliminates the issue for most attributes and a lot of elements.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page