Re: [xsl] Cheaper to prepend or append an item to a sequence?

Subject: Re: [xsl] Cheaper to prepend or append an item to a sequence?
From: Вячеслав Седов <schematronic@xxxxxxxxx>
Date: Tue, 22 Feb 2011 16:26:59 +0300
ops... is sequences and items not presented as pointers and linked
items? arrays? and what about lazy evaluation in this case? not every
time when we work with sequence we need whole sequence and in most
cases we don`t even need it as numbered

by the way - look like "except" keyword have same limitation - all
sequence need to be reconstructed instead of moving one of pointers
from one item to second

see this Schematron rule

    <pattern name="unique-id">
        <rule context="*[@id and not(ancestor-or-self::meta)]">
            <report test="@id = (//@id[not(ancestor::meta)] except @id)">
                same @id
            </report>
        </rule>
    </pattern>

and look like 'except' is bottleneck here - on huge documents
validation seems endless

2011/2/22 Michael Kay <mike@xxxxxxxxxxxx>:
> On 22/02/2011 11:27, Costello, Roger L. wrote:
>>
>> Hi Folks,
>>
>> When adding an item to a sequence, it is: (circle the correct answer)
>>
>> (a) Cheaper to add the item to the front of the sequence
>>
>> (b) Cheaper to add the item to the end of the sequence
>>
>> (c) Costs the same to add the item to the front or to the end
>>
>> (d) The cost varies depending on the XSLT processor
>>
>>
>
> (d) (As with all performance questions).
>
> It's not even a simple answer if you know the processor. Saxon will
> sometimes detect that appending to a sequence can be done without copying,
> either because the old sequence will never be used again, or because both
> can share the same storage - and even I find it difficult to predict the
> circumstances in which the optimizer will determine that such optimizations
> are feasible.
>
> Also, of course, cost is not one-dimensional: time and space both need to
be
> considered.
>
> Michael Kay
> Saxonica

Current Thread