xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] Possible optimization for getValue()
- From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- To: Hallvard Trætteberg <hal AT idi.ntnu.no>, <xom-interest AT lists.ibiblio.org>
- Cc:
- Subject: [XOM-interest] Possible optimization for getValue()
- Date: Thu, 25 Sep 2003 10:52:32 -0400
At 11:44 AM +0200 9/25/03, Hallvard Trætteberg wrote:
I also have a suggestion regarding Element's implementation of
Node.getValue(). It currently accumulates the childs' values in a
StringBuffer. In many cases there is only one child, and this could be
handled as a special case (for speed and reduced memory consumption), as
follows:
if (getChildCount() == 1) {
Node child = getChild(0);
if (child.isText() || child.isElement()) {
return child.getValue();
}
}
StringBuffer result = new StringBuffer();
for (int i = 0; i < getChildCount(); i++) {
...
}
return result.toString();
}
Of course, this complicates the code and may not increase the speed
much. However, the code is still fairly obvious, so why not?
Do you have any profiling data to indicate that this change is worthwhile?
--
Elliotte Rusty Harold
elharo AT metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA
-
[XOM-interest] XPath and Id handling for XOM,
Hallvard Trætteberg, 09/25/2003
- [XOM-interest] Possible optimization for getValue(), Elliotte Rusty Harold, 09/25/2003
- Re: [XOM-interest] XPath and Id handling for XOM, Elliotte Rusty Harold, 09/25/2003
- Re: [XOM-interest] XPath and Id handling for XOM, Elliotte Rusty Harold, 09/25/2003
Archive powered by MHonArc 2.6.24.