don't create VM proxies when we're just checking existence (VELOCITY-607)
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@680534 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/java/org/apache/velocity/runtime/VelocimacroFactory.java b/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
index 0af0dd7..bab730c 100644
--- a/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
+++ b/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
@@ -464,14 +464,8 @@
{
synchronized(this)
{
- /*
- * first we check the locals to see if we have
- * a local definition for this template
- */
- if (vmManager.get(vm, sourceTemplate) != null)
- return true;
+ return vmManager.has(vm, sourceTemplate);
}
- return false;
}
/**
diff --git a/src/java/org/apache/velocity/runtime/VelocimacroManager.java b/src/java/org/apache/velocity/runtime/VelocimacroManager.java
index af9159b..44ab912 100644
--- a/src/java/org/apache/velocity/runtime/VelocimacroManager.java
+++ b/src/java/org/apache/velocity/runtime/VelocimacroManager.java
@@ -160,6 +160,31 @@
}
/**
+ * determines if such a macro exists
+ * @param vmName Name of the Velocitymacro to look up.
+ * @param namespace Namespace in which to look up the macro.
+ */
+ public boolean has(final String vmName, final String namespace)
+ {
+ if (usingNamespaces(namespace))
+ {
+ Hashtable local = getNamespace(namespace, false);
+ if (local != null)
+ {
+ if (local.containsKey(vmName))
+ {
+ return true;
+ }
+ }
+ }
+ if (globalNamespace.containsKey(vmName))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
* gets a new living VelocimacroProxy object by the
* name / source template duple
* @param vmName Name of the VelocityMacro to look up.