xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] DOMConverter performance regression
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: xom-interest <xom-interest AT lists.ibiblio.org>
- Subject: Re: [XOM-interest] DOMConverter performance regression
- Date: Sat, 02 Oct 2004 11:19:32 -0400
I found another hot spot for this problem in ParentNode.indexOf. This one wasn't a surprise. I wrote a fix for it that shaves another 10-20% off the time:
private int lastPosition = -1;
public int indexOf(Node child) {
if (children == null) return -1;
// Programs tend to iterate through in order so we store the
// last index returned and check the one immediately after it
// first; before searching the list from the beginning.
lastPosition++;
if (lastPosition != children.size()) {
if (child == children.get(lastPosition)) {
return lastPosition;
}
else lastPosition = -1;
}
lastPosition = children.indexOf(child);
return lastPosition;
}
However the problem with this solution is that it adds another 4 bytes per element to XOM's memory footprint, and I don't think that's a price I'm willing to pay here. I'll see if I can fix the problem some other way that has less of a downside.
--
Elliotte Rusty Harold
elharo AT metalab.unc.edu
-
Re: [XOM-interest] DOMConverter performance regression,
Elliotte Harold, 10/02/2004
-
Re: [XOM-interest] DOMConverter performance regression,
Elliotte Harold, 10/02/2004
-
Re: [XOM-interest] DOMConverter performance regression,
Elliotte Harold, 10/02/2004
- Re: [XOM-interest] DOMConverter performance regression, John Cowan, 10/02/2004
-
Re: [XOM-interest] DOMConverter performance regression,
Elliotte Harold, 10/02/2004
-
Re: [XOM-interest] DOMConverter performance regression,
Elliotte Harold, 10/02/2004
Archive powered by MHonArc 2.6.24.