You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by nb...@apache.org on 2008/08/13 06:47:07 UTC
svn commit: r685437 -
/velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java
Author: nbubna
Date: Tue Aug 12 21:47:07 2008
New Revision: 685437
URL: http://svn.apache.org/viewvc?rev=685437&view=rev
Log:
for clarity, remove needless use of Map where a Set is appropriate
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/VelocimacroManager.java
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=685437&r1=685436&r2=685437&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 Tue Aug 12 21:47:07 2008
@@ -19,8 +19,10 @@
* under the License.
*/
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Map;
-
+import java.util.Set;
import org.apache.velocity.runtime.directive.VelocimacroProxy;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.SimpleNode;
@@ -51,8 +53,8 @@
/** Hash of namespace hashes. */
private final Map namespaceHash = MapFactory.create(17, 0.5f, 20, false);
- /** map of names of library tempates/namespaces */
- private final Map libraryMap = MapFactory.create(256, 0.5f, 10, false);
+ /** set of names of library tempates/namespaces */
+ private final Set libraries = Collections.synchronizedSet(new HashSet());
/*
* big switch for namespaces. If true, then properties control
@@ -88,14 +90,16 @@
public boolean addVM(final String vmName, final Node macroBody, final String argArray[],
final String namespace, boolean canReplaceGlobalMacro)
{
+ if (macroBody == null)
+ {
+ // happens only if someone uses this class without the Macro directive
+ // and provides a null value as an argument
+ throw new RuntimeException("Null AST for "+vmName+" in "+namespace);
+ }
+
MacroEntry me = new MacroEntry(vmName, macroBody, argArray, namespace);
me.setFromLibrary(registerFromLib);
-
- // this can happen only if someone uses this class without the Macro directive
- // and provides a null value as an argument
- if( macroBody == null )
- throw new RuntimeException("Null AST for "+vmName);
/*
* the client (VMFactory) will signal to us via
@@ -110,7 +114,7 @@
if (registerFromLib)
{
- libraryMap.put(namespace, namespace);
+ libraries.add(namespace);
}
else
{
@@ -122,7 +126,7 @@
* global
*/
- isLib = libraryMap.containsKey(namespace);
+ isLib = libraries.contains(namespace);
}
if ( !isLib && usingNamespaces(namespace) )