ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: [***Spam/VIR***] Re: Layer vs. overlay
Date: Wed, 16 Jan 2013 14:34:29 +0100	[thread overview]
Message-ID: <20130116133429.GC553@phlegethon.router_intern> (raw)
In-Reply-To: <op.wqz9hzsqtpjj8f@lpr>


[-- Attachment #1.1: Type: text/plain, Size: 1412 bytes --]

···<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.gesang@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


[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

      reply	other threads:[~2013-01-16 13:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 15:32 Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-11 18:06 ` Hans Hagen
2013-01-12  7:44 ` Wolfgang Schuster
2013-01-12 10:36   ` Procházka Lukáš
2013-01-12 13:25   ` Hans Hagen
2013-01-12 17:54   ` [***Spam/VIR***] " Procházka Lukáš
2013-01-12 18:11     ` Wolfgang Schuster
2013-01-15  8:04       ` Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-15 10:09         ` Wolfgang Schuster
2013-01-15 12:10           ` [***Spam/VIR***] " Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-15 12:25             ` Aditya Mahajan
2013-01-15 16:21               ` Philipp Gesang
2013-01-16  8:41               ` Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-16 11:47                 ` Philipp Gesang
2013-01-16 13:09                   ` Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-16 13:34                     ` Philipp Gesang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130116133429.GC553@phlegethon.router_intern \
    --to=philipp.gesang@alumni.uni-heidelberg.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).