[luatex] Strategy for creating a nodelist

Taco Hoekwater taco at elvenkind.com
Tue Mar 9 20:19:35 CET 2010


Hans Hagen wrote:
>> Looking at the documentation, node.insert_after() looks very much like 
>> what I want to use. But I don't quite understand its use when the head 
>> node is nil.

Both for speed and for ease of use when building a moderate node list
from scratch, the optimal solution is to only set the .next pointers
and use a single node.slide() when the construction is finished: this
is the fastest solution for any new list with non-trivial length, and
it takes the least amount of code.

When you have to splice one or two nodes into an existing node list,
node.insert_before/insert_after are probably better.

And for really short lists, .next and .prev are fine.


>>
>> For node.insert_after() I need a valid "current" node and a valid 
>> "new" node. But that would mean that I already have a head in form of 
>> the "current" node, right?

Yes. Starting a node list with insert_after() feels a bit clumsy,
because it was specifically written for splicing stuff into an
existing node list.

> in most cases you can forget about the prev as luatex itself will slide 
> when needed (in order to be sure of a proper list)

I want to get rid of those automatic slides by the executable as much
as possible: if everything on the lua side is behaving properly, they
should not be needed and only waste cpu cycles.

Best wishes,
Taco







More information about the luatex mailing list