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] Three cosmetic patches
- Date: Mon, 09 Feb 2004 15:42:41 -0800
Here are some cosmetic patches against d24.
The first two avoid some code duplication, and the third makes it a bit more efficient.
Wolfgang.
in class ParentNode:
public Node removeChild(Node child) {
//if (children == null) {
// throw new NoSuchChildException(
// "Child does not belong to this node"
// );
//}
// This next line is a hotspot
//int position = children.indexOf(child);
int position = this.indexOf(child);
if (position == -1) {
throw new NoSuchChildException(
"Child does not belong to this node"
);
}
return removeChild(position);
//checkRemoveChild(child, position);
//children.remove(position);
//child.setParent(null);
//return child;
}
public final void replaceChild(Node oldChild, Node newChild) {
//if (children == null) {
// throw new NoSuchChildException(
// "Reference node is not a child of this node."
// );
//}
//int position = children.indexOf(oldChild);
int position = this.indexOf(oldChild);
if (position == -1) {
throw new NoSuchChildException(
"Reference node is not a child of this node."
);
}
removeChild(position);
insertChild(newChild, position);
}
in class Element:
private static boolean isAncestor(Node parent, Node child) {
//if (child == parent) return true;
//if (parent == null) return false;
//else return isAncestor(parent.getParent(), child);
// for efficiency avoid recursion in favour of iteration
while (true) {
if (child == parent) return true;
if (parent == null) return false;
parent = parent.getParent();
}
}
-
[XOM-interest] Three cosmetic patches,
Wolfgang Hoschek, 02/09/2004
-
Re: [XOM-interest] Three cosmetic patches,
Elliotte Rusty Harold, 02/10/2004
-
Re: [XOM-interest] Three cosmetic patches,
Wolfgang Hoschek, 02/10/2004
-
Re: [XOM-interest] Three cosmetic patches,
jcowan, 02/10/2004
-
Re: [XOM-interest] Three cosmetic patches,
Elliotte Rusty Harold, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
jcowan, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
Elliotte Rusty Harold, 02/11/2004
- Re: [XOM-interest] Three cosmetic patches, jcowan, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
Elliotte Rusty Harold, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
jcowan, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
Elliotte Rusty Harold, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
Wolfgang Hoschek, 02/11/2004
- Re: [XOM-interest] Three cosmetic patches, Francois Beausoleil, 02/11/2004
-
Re: [XOM-interest] Three cosmetic patches,
jcowan, 02/10/2004
-
Re: [XOM-interest] Three cosmetic patches,
Wolfgang Hoschek, 02/10/2004
- <Possible follow-up(s)>
- Re: [XOM-interest] Three cosmetic patches, Trimmer, Todd, 02/12/2004
-
Re: [XOM-interest] Three cosmetic patches,
Elliotte Rusty Harold, 02/10/2004
Archive powered by MHonArc 2.6.24.