Re: [xsl] XSLT 2.0 function - fastest node comparison

Subject: Re: [xsl] XSLT 2.0 function - fastest node comparison
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 10 Mar 2005 14:05:25 GMT
you never need to write

 if (something) then true() else false()

you could just use 

  something

which must work the same way in a boolean context , as otherwise the
if() test wouldn't have worked.

If you want to force it to be boolean you coul do

boolean(something)

although boolean is slightly different from the efective boolean value
(unless things have changed again) I'll get that wrong unless I checked
it up again so Michael might pick this comment up...

I doubt that makes any difference at all to the efficiency though (it
might make no difference to the compiled code for all I know)

If your ranges are just general ranges I suspect that your actual test is
the best that could be done. If your ranges are a non-overlapping
monotonically increasing sequence of ranges, and you had enough of them
that optimising this was worth it,  there is probably some other
data structure you could use that would tell the system that the
sequence  was monotonicly increasing so it could stop and return false
once it had "gone past" the char. Nothing springs to mind immediately.

so with your example posted given an input of 5 I would guess that you
can return false immediately (or at least after seeing the first range
starts at 988) but your suggested code will check all the ranges.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread