[Dive4elements-commits] [PATCH] Datacage: Macros are indexed, so there is no need to linear scan all template nodes to find them
Wald Commits
scm-commit at wald.intevation.org
Sat May 25 08:15:08 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1369462496 -7200
# Node ID a02d27da17ca2c93c595e9a6d8b195274d846dc7
# Parent 6e99ce50586082577c00612f82a859b3ec029853
Datacage: Macros are indexed, so there is no need to linear scan all template nodes to find them.
diff -r 6e99ce505860 -r a02d27da17ca artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java Fri May 24 18:53:35 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java Sat May 25 08:14:56 2013 +0200
@@ -768,23 +768,11 @@
/** Get macro node children, not resolving bodies. */
protected NodeList getMacroChildren(String name) {
- NodeList macros = template.getElementsByTagNameNS(
- DC_NAMESPACE_URI, "macro");
- Element macro = null;
-
- for (int i = 0, N = macros.getLength(); i < N; ++i) {
- Element m = (Element) macros.item(i);
- if (name.equals(m.getAttribute("name"))) {
- macro = m;
- break;
- }
- }
-
- if (macro != null) {
- return macro.getChildNodes();
- }
- return null;
+ Element macro = macros.get(name);
+ return macro != null
+ ? macro.getChildNodes()
+ : null;
}
protected void ifClause(Node parent, Element current)
More information about the Dive4elements-commits
mailing list