[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: SAX2: Namespace proposal

  • From: Miles Sabin <msabin@c...>
  • To: David Megginson <david@m...>, xml-dev@i...
  • Date: Mon, 20 Dec 1999 15:13:55 -0000

intern java
David Megginson wrote,
> Miles Sabin wrote,
> > 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.

Ditto, using a very nice data structure that John Cowan brought
to my attention, see,

http://www.ddj.com/articles/1998/9804/9804a/9804a.htm

which has turned out to be considerably faster than hash tables
(nb. hash tables _generally_ not just java.util.Hashtable or
java.util.HashMap) for our applications.

> 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.

Try it, but I think you'll be more likely to lose than gain.

> > 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.

Agreed.

But all this seems to suggest that the use of java.lang.String.
intern() and java.util.Hashtable isn't that good an idea.
Insofar as SAX defines interfaces you can leave the choice to
implementors. But wiring them into the implementation of SAX 
utility classes (eg. your NSUtils) would mean that we don't
get the option.

Cheers,


Miles

-- 
Miles Sabin                       Cromwell Media
Internet Systems Architect        5/6 Glenthorne Mews
+44 (0)20 8817 4030               London, W6 0LJ, England
msabin@c...          http://www.cromwellmedia.com/


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



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.