<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">replying on-list on one topic, as this will be relatively brief (off-list material at start but last topic is luatex related):<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Le 3 août 2021 à 19:10, Hans Hagen <<a href="mailto:j.hagen@xs4all.nl" class="">j.hagen@xs4all.nl</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" style="font-family: Courier; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">I have also not tried to optimise how this \Replicate should be used, deciding to nest it with an inner one replicating 1000 times, but never testing if that was actually good. [...]<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Courier; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Courier; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">maybe don't pass the number but put it in a register ; </span></div></div></blockquote><div><br class=""></div>first thing that the macro does anyhow is to make sure it handles explicit digits, the original used \the\numexpr and this version sticks to Knuth and has a reduced interface requiring user to call it with explicit digits or with « \the\somecount » so a single \expandafter does the job.</div><div><br class=""></div><div>And in inner inner loops, only a variant doing hard-coded 1000 repetitions is used and has no argument</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Courier; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">this romannumeral is also kind of strange (not sure why you need it </span></div></div></blockquote><div><br class=""></div><div>you are absolutely right. It serves nothing in this context. The original is from an area where I provide most macros in two forms say « \Foo » and « \foo » where \Foo expands to \romannumeral\foo (to be precise rather \romannumeral0\foo due to legacy reasons of relative ignorance 8 years ago, but here for this replicate, it is indeed \romanumeral\foo). This means you can do \expandafter\Stuff\romannumeral\foo rather than \expandafter\expandafter\expandafter\Stuff\Foo.</div><div><br class=""></div><div>In the case at hand the core expansion is anyhow \csname governed and one could re-organize stuff so that \Foo would be \csname\foo rather, with some micro gain. But this would have been at odds with the style in the original codebase from which it is extracted.</div><div><br class=""></div><div>In this specific usage, definitely I could drop the \romannumeral and the paired closing \z@. Will keep this in mind when I will review sieve code for small improvements.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Courier; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">; actually you should time romannumeral in pdftex vs luatex .. could be more efficient in thelater</span><br style="caret-color: rgb(0, 0, 0); font-family: Courier; font-size: 16px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></div></blockquote></div><br class=""></div><div class="">The \romannumeral in my context (sic) are only there to trigger and end expansion... I needed to scratch a bit my head to benchmark that in a way allowing to compare pdftex vs luatex, and I am not sure I do it right. But here we go, typical results on my hardware are listed below and are... surprising to me.</div><div class=""><br class=""></div><div class=""><div class="">-------- START OF TEST FILE</div><div class="">\long\def\Lots#1{\Repx{\Repm{#1}}}% 10000</div><div class="">\long\def\Repm#1{\Repc{#1#1#1#1#1#1#1#1#1#1}}</div><div class="">\long\def\Repc#1{\Repx{#1#1#1#1#1#1#1#1#1#1}}</div><div class="">\long\def\Repx#1{#1#1#1#1#1#1#1#1#1#1}</div><div class=""><br class=""></div><div class="">\ifdefined\directlua</div><div class="">% copied from <a href="https://tex.stackexchange.com/a/32531" class="">https://tex.stackexchange.com/a/32531</a></div><div class=""> \directlua{pdfelapsedtimer_basetime=0}%</div><div class=""> \def\pdfresettimer{\directlua{pdfelapsedtimer_basetime = os.clock()}}%</div><div class=""> \def\pdfelapsedtime{\numexpr\directlua{tex.print(math.floor((os.clock()-pdfelapsedtimer_basetime)*65536+0.5))}\relax}%</div><div class="">\fi</div><div class=""><br class=""></div><div class="">\catcode`@ 11</div><div class="">%\def\empty{}</div><div class="">%\z@ is a dimen set to 0pt</div><div class="">\let\Tall\z@</div><div class="">\let\Uall\z@</div><div class=""><br class=""></div><div class="">\Repx{%</div><div class="">\immediate\write128{}%</div><div class="">\pdfresettimer</div><div class="">\Lots{\romannumeral\Repm\empty\z@}% 10000 times a r triggered silly expan.</div><div class="">\edef\T{\the\dimexpr\pdfelapsedtime sp}%</div><div class="">\immediate\write128{with: \T}%</div><div class="">\pdfresettimer</div><div class="">\Lots{\Repm\empty}%</div><div class="">\edef\U{\the\dimexpr\pdfelapsedtime sp}%</div><div class="">\immediate\write128{without: \U}%</div><div class="">% update totals</div><div class="">\edef\Tall{\the\dimexpr\Tall+\T}%</div><div class="">\edef\Uall{\the\dimexpr\Uall+\U}%</div><div class=""><br class=""></div><div class="">% always strange things with timer so redo it with order reversed after a \par</div><div class="">\pdfresettimer</div><div class="">\Lots{\Repm\empty}%</div><div class="">\edef\U{\the\dimexpr\pdfelapsedtime sp}%</div><div class="">\immediate\write128{without: \U}%</div><div class="">\pdfresettimer</div><div class="">\Lots{\romannumeral\Repm\empty\z@}% 10000 times a r triggered silly expan.</div><div class="">\edef\T{\the\dimexpr\pdfelapsedtime sp}%</div><div class="">\immediate\write128{with: \T}%</div><div class=""><br class=""></div><div class="">% update totals</div><div class="">\edef\Tall{\the\dimexpr\Tall+\T}%</div><div class="">\edef\Uall{\the\dimexpr\Uall+\U}%</div><div class="">}%</div><div class=""><br class=""></div><div class="">\immediate\write128{}</div><div class="">\immediate\write128{with (total): \Tall}</div><div class="">\immediate\write128{without (total): \Uall}</div><div class="">\immediate\write128{with minus without: \the\dimexpr\Tall-\Uall}</div><div class="">\bye</div><div class="">-------- END OF TEST FILE</div><div class=""><br class=""></div><div class="">% pdftex</div><div class="">with (total): 5.34964pt</div><div class="">without (total): 5.45686pt</div><div class="">with minus without: -0.10722pt</div><div class=""><br class=""></div><div class="">with (total): 5.55394pt</div><div class="">without (total): 5.61536pt</div><div class="">with minus without: -0.06142pt</div><div class=""><br class=""></div><div class="">with (total): 5.35501pt</div><div class="">without (total): 5.3827pt</div><div class="">with minus without: -0.0277pt</div><div class=""><br class=""></div><div class="">% luatex</div><div class="">with (total): 6.08586pt</div><div class="">without (total): 6.30107pt</div><div class="">with minus without: -0.21521pt</div><div class=""><br class=""></div><div class="">with (total): 6.06969pt</div><div class="">without (total): 6.35312pt</div><div class="">with minus without: -0.28343pt</div><div class=""><br class=""></div><div class="">with (total): 6.11238pt</div><div class="">without (total): 6.37778pt</div><div class="">with minus without: -0.2654pt</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Conclusion is that it seems to *speed up* « expanding to empty » to *add* \romannumeral wrapper.... </div><div class=""><br class=""></div><div class="">and indeed with luatex the relative gain is even higher than with pdftex... implying \romannumeral is even more efficient there</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Kind regards</div><div class="">Jean-François</div></body></html>