Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] DOMConverter performance regression

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • 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




Archive powered by MHonArc 2.6.24.

Top of Page