OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: SAX2: Namespace proposal

[ Lists Home | Date Index | Thread Index ]
  • From: David Megginson <david@megginson.com>
  • To: xml-dev@ic.ac.uk
  • Date: Mon, 20 Dec 1999 09:58:53 -0500 (EST)

Miles Sabin writes:
 > David Megginson wrote,
 > > Stefan Haustein wrote,
 > > > - building a new object seems some overhead at the first 
 > > > sight, but in JAVA also a new String is a new object...
 > >
 > > And that is why most parsers internalize strings rather than 
 > > creating new ones,
 > 
 > This isn't necessarily the best approach. Intern'ing a string
 > involves a lookup in a JVM-internal hash table. This table is
 > shared across all threads, and consequently has to be locked
 > against simultaneous reads and updates.

That's probably why most parsers have their own intern routines rather 
than using java.lang.String.intern -- at least, I wrote a custom
hashing and interning routine for AElfred that sped it up quite
significantly over (a) using java.lang.String.intern() or (b)
allocating a new string for every element name.  If I were doing it
over, though, I would actually call java.lang.String.intern once for
each of the strings in the intern table so that they were == to the
regular intern'ed versions.

 > It's also worth remembering that you've got to _already_ have
 > a String before you can intern it! If you've just created one
 > (eg. from a portion of a char array) then you're only going to
 > add overhead by doing an intern in addition.

Again, I avoided this problem by building my own intern and hashing
methods in AElfred.  There's no reason that a hash table should not be
able to use an array as a key -- Java's Hashtable just doesn't happen
to be designed that way.


All the best,


David

-- 
David Megginson                 david@megginson.com
           http://www.megginson.com/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS