changeset 6097:a02d27da17ca

Datacage: Macros are indexed, so there is no need to linear scan all template nodes to find them.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sat, 25 May 2013 08:14:56 +0200
parents 6e99ce505860
children c21bfa653942
files artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/Builder.java
diffstat 1 files changed, 4 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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)

http://dive4elements.wald.intevation.org