xsl-list
[Top] [All Lists]

XPath expr optimization (was Re: monotonous...)

2002-11-14 13:03:38
Greg Faron wrote:
At 05:47 PM 11/13/2002, you wrote:
Greg Faron wrote:
normalize-space(string-length(.)) = 0

That's a lot of extra work.

isn't this one of those things that the better XSLT engines will 
optimize to the best form?

Not unless the people writing the engine have reason to believe it will be
faster to look ahead into and analyze an expression and find ways it can be
optimized than to just evaluate it as-is.

I also suppose that the "best form" could be 
XSLT engine-dependent, but probably it is "not(string())".

Hmm. In order to determine if not() is applicable, you have to evaluate the
right subexpression to see if it is the number zero or boolean false. You were
going to do a "is the number on the left equal to the number on the right?"
but now you're asking "if the thing on the right turns out to be a number, is
it equal to zero? or if the thing on the right turns out to be a boolean, is
it equal to false?". Even if you don't evaluate the right subexpression and
just look for the token '0' in the expression string itself, you're asking "is
it the string '0'?" which is another equality comparison. If all such equality
comparisons are equally expensive, where is the optimization?

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>