···<date: 2013-01-16, Wednesday>···<from: Procházka Lukáš Ing. - Pontex s. r. o.>···
> Hello, > > On Wed, 16 Jan 2013 12:47:21 +0100, Philipp Gesang > <philipp.ges...@alumni.uni-heidelberg.de> wrote: > > >Lookup the correct string from a table? > > thanks for the idea - > > - in other words, we have to keep running results somewhere; Yes, this is simple because the order of processing doesn’t change -- as long as the data you aggregate fits into your memory, of course! > the algorithm fills a table with texts for each page, and each > \setlayer takes one value back, so we can simplify to: > </snip> > \setlayer[beforetext][preset=righttop] > {\framed[width=2in]{\directlua{context(table.remove(userdata.LPr.texts, > 1))}}} </snip> > context.startTEXpage { background = "foreground,beforetext" } > table.insert(userdata.LPr.texts, "BEF" .. i) > > context.externalfigure({"cow"},{width="30cm"}) > context.stopTEXpage() From my tests calling table.remove() to remove the first element in a list is extremely inefficient compared to accessing an array. (For 10^5 elements it’s 1m41.644s vs. 0m0.030s on my machine.) While we’re at it, table.insert() involves an extra function call that carries another perfomance penalty, albeit a much smaller one. Your code should do the same, though. Regards Philipp
pgpj538CZkQxC.pgp
Description: PGP signature
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________