tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul P Akolkar <akol...@us.ibm.com>
Subject Re: Odd behavior of Number/String conversion??
Date Tue, 08 Mar 2005 23:23:52 GMT
Rick wrote:

> Thanks Rahul for the info. I'm wondering which would have 
> less overhead behind the scenes... using the replace like
> you have it above or storing    what I want to replace in
> a temp var? The reason I ask is this operation will have
> to actually be repeated several times within an outer loop.

For your example, it doesn't matter.

First off, performance discussions will be container specific. In the 
reference implementation (tomcat/jasper), when o.a.j.compiler.Generator 
gets you the Servlet class to compile, you'll find a bunch of 
PageContextImpl.proprietaryEvaluate() calls in the code, which are in turn 
using commons.el to do the actual EL evaluation. An rtexpr true tag 
attribute will be sent to commons.el expression evaluator impl as-is, a 
standalone EL expression is broken down in an ordered list of ELNode.Text, 
ELNode.Root, ELNode.Function nodes (broken down once per JSP mod) so only 
the true expression snippets make it to EL evaluation. There are a bunch 
of StringBuffer manipulations along most of these steps, fn:replace() has 
its own StringBuffer manipulations, and in the larger scheme of things, 
for the example we're discussing, the difference in overheads is 
definitely nothing to lose sleep over ;-) Take your pick.

If you want to pursue this, try a simple (t2-t1) timing study on the two 
options. I'd be very surprised if either option comes out a clear winner.

-Rahul

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message