Morten Jorgensen <[EMAIL PROTECTED]> wrote:
> as long as these identifiers are in sequence,
> there is no need for any string concatenations or other string
operations.

Yes, I agree.  I don't think this is a huge deal, it just needs a bit of
rework in the DTM.

> What parts do we need to rewrite? I am probably very optimistic, but I
was
> hoping to just split the current functionality in two.

Yes, I think you misunderstood me.  By rewrite, I just meant the structural
optimization rewrites I mentioned below.

> Maybe we should evaluate the size of the input and chose one of the
> two methods based on that?

I think it's pretty hard to do this based on stream information?

> These are unknown waters for me, so please be patient with me....
> Can you give me a few examples of such optimisations?

I'm no expert on functional language optimizations either.  But...

1) Redundent expression elimination.  Take common front part of expressions
and make a sort of magic variable out of them.  Somewhere I have a really
good example of this, but I can't find it right now.

2) Related to that, globalization of root expressions such as
"//products/product[category=current()/id]".  You see many stylesheets
where this is evaluated over and over.

3) Result Tree Fragments can be somewhat expensive (I don't know how you do
RTFs in XSLTC yet).  Often, you can turn these into select statements.

4) Tail recursion elimination.  This is especially important because
recursion is used so much in xslt.

5) Inlining (I think there are a fair number of opportunities for this).

There are other things you can do based on analysis of the AST:

1) Tell if a given select expression can be easily evaluated in doc order,
without sorting.

2) Tell if an index predicate is used or might be used in a select
expression.  In particular, this helps to rewrite "//foo[@baz]" as
/descendant:foo[@baz], instead of /descendant-or-self::node/child::foo
[@baz].  The first is an even bigger difference than it would first appear,
because /descendant:foo[@baz] can easily return in document order, while
the same is not true of /descendant-or-self::node/child::foo[@baz].

3) Tell if the stylesheet can be processed in pure streaming mode, i.e. you
don't have to construct an entire source tree.

4) Tell at what points parts of source trees can be discarded.

5) Tell at what points document(...) trees can be discarded.

I'm sure there are lots more in these two categories that I'm not recalling
right now.

-scott





Reply via email to