[jdom-interest] XPath support

Elliotte Rusty Harold elharo at metalab.unc.edu
Sun Sep 1 06:49:06 PDT 2002

At 9:17 AM -0400 8/29/02, bob mcwhirter wrote:

>It may be ugly, but if they could tag their nodes with an numeric
>node-type, we could rid ourselves of lots of instanceof checks in the

That seems to be a very bad idea to me. Even if you could use a 
profiler to prove this is a performance bottleneck, you'd still be 
duplicating a core language feature with an extra-language 
convention. It's entirely possible that in a future release of Java 
or a different VM instanceof would be sped up to the point where it 
was not a bottleneck and might well be faster than the integer type 
codes you suggest. A very similar thing happened with strings between 
Java 1.0 and 1.1? a few years ago.

The original String class was so slow that a lot of high performance 
applications invented their own String class. Then Sun fixed the 
problems in the String class and suddenly, the optimizers were stuck 
with a lot of messy code to maintain that didn't perform as well as 
the naive code that used the standard String class.  The same thing 
happened with synchronization a couple of version later. One of 
JDOM's claim to fame is that it's Java native, and uses Java 
facilities wherever available. I don't think this should change.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
|              http://www.cafeconleche.org/books/xian2/              |
|  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/  |
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |

More information about the jdom-interest mailing list