Rik Kabel schrieb am 15.11.2021 um 22:51:
Wolfgang,
Can you expand on the following statements from your reply?
You can run Hans example with MkIV and the differences should be
even bigger because the check for [] is slower here while in LMTX
it's a engine feature. The main difference in LMTX is a extra
expansion for \setup compared to \directsetup.
there is no difference between \setup and \directsetup
Are you saying:
1. When [] are used with \setup, expansion of the contents is done
differently than when {} are used.
It doesn't matter which form you use for \setup.
What I'm trying to say is that \setup is slower (or better was slower in
MkIV) than \directsetup because \setup has to check first if the name is
passed within brackets or as normal argument in braces.
The code in MkIV would look similar to this:
\def\setup
{\doifnextcharelse[
\setup_brackets
\setup_braces}
\def\setup_brackets[#1]%
{\directsetup{#1}}
\def\setup_braces#1%
{\directsetup{#1}}
2. There is no significant processing time difference between \setup
and \directsetup.
When I run the following example on my machine
\starttext
\startsetups [dummy]
\stopsetups
\testfeatureonce{100000}{\setup {test}} \elapsedtime \par
\testfeatureonce{100000}{\directsetup{test}} \elapsedtime \par
\stoptext
I get these times.
# MkIV
\setup : 0.136s
\directsetup : 0.079s
# LMTX
\setup : 0.083 seconds
\directsetup : 0.071 seconds
Add additional stuff in the setup environment and the difference between
\setup and \directsetup doesn't matter anymore.
3. There is additional expansion performed for \setup compared to
\directsetup.
Although this isn't completely true (but very close) the definition for
\setup in LMTX is like this:
\def\setup#1{\directsetup{#1}}
4. Under LMTX, because {} and [] handling overhead is so similar, the
most visible processing time difference to users is from the
difference in expansion between \setup and \directsetup.
I think you are saying that 2, 3, and 4 are true, but that 1 is not true.
If that is the case, can you provide an example that demonstrates the
difference in expansion between \setup and \directsetup?
Also, as far as expansion, is \fastsetup like \setup or like \directsetup?
\setup and \directsetup are similar. \fastsetup is like the name implies
a faster version which ignores grid mode and doesn't care whether the
requested environment even exists.
My simple testing shows no difference between setup, directsetup, and
fastsetup for namespace set and reset. Is it your understanding that
they all behave the same?
No, \fastsetup behaves different because it leaves \relax\empty in the
input when you pass the name of a not existing environment.
It shouldn't matter in normal usage but below are two examples.
Example 1:
\starttext
\tex{directsetup}
\scratchcounter 12\directsetup{unknown_a}34
\the\scratchcounter
\tex{fastsetup}
\scratchcounter 12\fastsetup{unknown_b}34
\the\scratchcounter
\stoptext
Example 2:
\starttext
\normalexpanded{\noexpand\firstoftwoarguments\directsetup{unknown_a}xy}
\normalexpanded{\noexpand\firstoftwoarguments\fastsetup{unknown_b}xy}
\stoptext
Wolfgang
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________