[luatex] robustness of node.traverse

Hans Hagen pragma at wxs.nl
Sat Nov 10 00:09:49 CET 2012


On 11/9/2012 8:19 PM, Stephan Hennig wrote:

> What is the advantage of this to the naive
>
>    local n = head
>    while n do
>      ...
>      n = n.next
>    end

convenience

> Regarding traverse_id

> Again, what is the advantage of this to the naive
>
>    local n = head
>    while n do
>      if n.id == <id> then
>        ...
>      end
>      n = n.next
>    end

speed, as in jumps over (successive) nodes that don't match id and it 
saves at least one function call per lookup.

Anyhow, it all depends on the kind of code you write. In practice node 
lists are relatively small so you can choose the loop method that you 
like most. So, when you manipulate the list, the method that you call 
'naive' is often the most suitable.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list