xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Wolfgang Hoschek <whoschek AT lbl.gov>
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] Attributes performance patch
- Date: Sun, 21 Nov 2004 17:06:39 -0800
When bnux deserializing I noticed Attributes.checkPrefixConflict and Attributes.get(String) as prominent hotspots.
This is with a WURFL document such as this one here: http://wurfl.sourceforge.net/wurfl.zip
The patch below eliminates some unnecessary iteration and uses indexes instead of iterators. Makes the hotspot completely go away. Otherwise, behaviour is unchanged.
void checkPrefixConflict(Attribute attribute) {
String prefix = attribute.getNamespacePrefix();
String namespaceURI = attribute.getNamespaceURI();
// Look for conflicts
// Iterator iterator = attributes.iterator();
// while (iterator.hasNext()) {
// Attribute a = (Attribute) iterator.next();
for (int i=attributes.size(); --i >= 0; ) {
Attribute a = (Attribute) attributes.get(i);
if (a.getNamespacePrefix().equals(prefix)) {
if (a.getNamespaceURI().equals(namespaceURI)) return; // no need to look further
// there can't be any more attrs with the same prefix but different URI.
// the original code would continue to iterate over the remaining attributes!
throw new NamespaceConflictException(
"Prefix of " + attribute.getQualifiedName()
+ " conflicts with " + a.getQualifiedName());
}
}
}
Attribute get(String localName, String namespaceURI) {
// Iterator iterator = attributes.iterator();
// while (iterator.hasNext()) {
// Attribute a = (Attribute) iterator.next();
for (int i=attributes.size(); --i >= 0; ) {
Attribute a = (Attribute) attributes.get(i);
if (a.getLocalName().equals(localName)
&& a.getNamespaceURI().equals(namespaceURI)) {
return a;
}
}
return null;
}
-
[XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/21/2004
-
Re: [XOM-interest] Attributes performance patch,
Elliotte Harold, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Elliotte Harold, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Elliotte Harold, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/22/2004
- Re: [XOM-interest] Attributes performance patch, Elliotte Harold, 11/23/2004
- Re: [XOM-interest] Attributes performance patch, Elliotte Harold, 11/23/2004
- Re: [XOM-interest] Attributes performance patch, Wolfgang Hoschek, 11/23/2004
- Re: [XOM-interest] Attributes performance patch, Elliotte Harold, 11/23/2004
-
Re: [XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Elliotte Harold, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Elliotte Harold, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Wolfgang Hoschek, 11/22/2004
-
Re: [XOM-interest] Attributes performance patch,
Elliotte Harold, 11/22/2004
Archive powered by MHonArc 2.6.24.