velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r680534 - in /velocity/engine/trunk/src/java/org/apache/velocity/runtime: VelocimacroFactory.java VelocimacroManager.java
Date Mon, 28 Jul 2008 22:12:38 GMT
Author: nbubna
Date: Mon Jul 28 15:12:36 2008
New Revision: 680534

URL: http://svn.apache.org/viewvc?rev=680534&view=rev
Log:
don't create VM proxies when we're just checking existence (VELOCITY-607)

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java?rev=680534&r1=680533&r2=680534&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroFactory.java Mon
Jul 28 15:12:36 2008
@@ -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;
     }
 
     /**

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java?rev=680534&r1=680533&r2=680534&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java Mon
Jul 28 15:12:36 2008
@@ -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.



Mime
View raw message