[jdom-interest] a question about node type

Elliotte Harold elharo at metalab.unc.edu
Thu Dec 7 05:05:11 PST 2006


Syloke Soong wrote:
> [quote]
> instanceof is reflection and reflection is slow :).
> [/quote]
> 
> Omg[osh], I've got instanceof operator all over the place. Though it
> seems my IO operations that are slowing my apps down.
> 

Then your I/O operations are pretty damn slow. :-)

In my profiling in another project, the one guarantee was that any 
method that called instanceof was a performance sink. If it was used in 
a loop it was even worse. I went to great lengths internally to almost 
completely eliminate instanceof from my code.

Plus, instanceof is usually an indication of failure of the object 
model. Polymorphism should normally replace instanceof and similar 
checks, though you can't always do that when working with other people's 
code.


-- 
Elliotte Rusty Harold  elharo at metalab.unc.edu
Java I/O 2nd Edition Just Published!
http://www.cafeaulait.org/books/javaio2/
http://www.amazon.com/exec/obidos/ISBN=0596527500/ref=nosim/cafeaulaitA/


More information about the jdom-interest mailing list