Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Some minor issues

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: Wolfgang Hoschek <whoschek AT lbl.gov>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Some minor issues
  • Date: Sun, 05 Dec 2004 05:48:13 -0500

Wolfgang Hoschek wrote:

I'd like to bring up a few minor issues for clarification.

1) Element copy constructor

In my use cases it is extremely common to use new Element(Element), copying an element with no children, no attributes and no namespaces, later adding children separately. This improves performance (avoids reverification and indexOf) and saves memory (avoids new String creations), leading to a form of string interning that helps performance elsewhere. But Element.nonrecursiveCopy() is quite inefficient for that case, even though there's really nothing to do for it, since there are no children. The fix is to have:

public Element(Element elem) {
...
this.actualBaseURI = element.findActualBaseURI();
if (getChildCount() > 0) // WH patch; avoid work if there's nothing to do anyway
nonrecursiveCopy(element, this);

[You could also move the getChildCount() > 0 check into nonrecursiveCopy() if desired]

This is a a nice idea. Thanks! I do think it would be a good idea to move the check into nonrecursiveCopy as you suggest so it speeds up the copy() method too. I'll put this on the TODO list. I already have a copy benchmark so maybe this won't take too long.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim




Archive powered by MHonArc 2.6.24.

Top of Page