velocity-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Byron Foster <by...@base2.cc>
Subject Possible macro optimization
Date Wed, 01 Oct 2008 17:40:05 GMT
I was considering the possibility that references within macros could  
be optimized. Given the following:

#macro(foo $a $b)
   $a $b
#end

#foo($c $d.e)

Currently both $a $b within the macro are referenced by AST.  However,  
with some compile time analysis it can be determined that $a and $b  
can be referenced directly from the macro context (just like variables  
outside of a macro).  The analysis can determine that $c and $d are  
not modified during the macro call by walking the AST tree and  
insuring these references do not exist within the macro.  Not only  
could the AST be removed, but the value $d.e could be passed in to $b  
which would avoid looking up the 'e' property on $d every time $b is  
referenced.  This would also save memory since the AST nodes for all  
the references in the macro could be removed.  Anyone see a problem  
with this?


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


Mime
View raw message