Author: byron
Date: Sat Jan 3 20:24:43 2009
New Revision: 731167
URL: http://svn.apache.org/viewvc?rev=731167&view=rev
Log:
VELOCITY-662 Reduce performance bottleneck with the referenceInsert event
handler call
Modified:
velocity/engine/trunk/src/changes/changes.xml
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Modified: velocity/engine/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=731167&r1=731166&r2=731167&view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Sat Jan 3 20:24:43 2009
@@ -27,6 +27,10 @@
<body>
<release version="1.7" date="In Subversion">
+ <action type="add" dev="byron" issue="VELOCITY-662">
+ Reduce performance bottleneck with the referenceInsert event handler
call
+ </action>
+
<action type="add" dev="byron" issue="VELOCITY-656">
Better error reporting when toString() throw an exception when testing
an #if conditional. For example #if($foo)
Modified:
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL:
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=731167&r1=731166&r2=731167&view=diff
==============================================================================
---
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++
velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Sat Jan 3 20:24:43 2009
@@ -134,6 +134,9 @@
numChildren = jjtGetNumChildren();
+ // This is an expensive call, so get it now.
+ literal = literal();
+
/*
* and if appropriate...
*/
@@ -381,7 +384,7 @@
* if we have an event cartridge, get a new value object
*/
- value = EventHandlerUtil.referenceInsert(rsvc, context, literal(),
value);
+ value = EventHandlerUtil.referenceInsert(rsvc, context, literal,
value);
String toString = null;
if (value != null)
@@ -939,43 +942,4 @@
}
return obj;
}
-
-
- /**
- * Routine to allow the literal representation to be
- * externally overridden. Used now in the VM system
- * to override a reference in a VM tree with the
- * literal of the calling arg to make it work nicely
- * when calling arg is null. It seems a bit much, but
- * does keep things consistant.
- *
- * Note, you can only set the literal once...
- *
- * @param literal String to render to when null
- */
- public void setLiteral(String literal)
- {
- /*
- * do only once
- */
-
- if( this.literal == null)
- this.literal = literal;
- }
-
- /**
- * Override of the SimpleNode method literal()
- * Returns the literal representation of the
- * node. Should be something like
- * $<token>.
- * @return A literal string.
- */
- public String literal()
- {
- if (literal != null)
- return literal;
-
- // this value could be cached in this.literal but it increases memory
usage
- return super.literal();
- }
}