[latex3-commits] [git/LaTeX3-latex3-latex2e] apdf161: Simplify a bit \@@_make_name:n (e6a1a69e)

Phelype Oleinik tex.phelype at gmail.com
Thu Sep 10 12:07:28 CEST 2020


On Wed, Sep 9, 2020 at 11:48 AM Bruno Le Floch <blflatex at gmail.com> wrote:
>
> > -          { \tl_gset:co {@@~#1}
> > -                        {\cs:w g_@@_#1_code_next_tl \cs_end: } }
> > +          { \tl_gset:co { @@~#1 }
> > +                        { \cs:w g_@@_#1_code_next_tl \cs_end: } }
>
> I wonder if it would be nicer to call it \cs:w @@_next~#1 \cs_end: to match the
> @@~#1 (note I was careful to avoid name clashes, you cannot do @@~next_#1 or
> similar).

Hm...  It might appear in error messages, as the main token list, even
if we don't need to do fancy \csname stuff with it.  Might as well go
into the same package.

> > -\cs_new:Npn \@@_use_undefined:w #1 #2 \use:n #3 #4 \cs_end:
> > +\cs_new:Npn \@@_use_undefined:w #1 #2 @@~#3 \cs_end:
>
> Unsafe.  The \use:n was there so that a \cs_end: inside the hook name wouldn't
> mark the end of the argument of \@@_use_undefined:w.

Ouch, I completely overlooked that.  I thought that the \use:n thingy
was just so that the actual hook name could be easily extracted from
within the \cs:w...\cs_end:.

> One safe and fast option would be
>
> \cs_new_eq:NN \@@_use_end: \cs_end:
>
> and use \@@_use_end: as the end-marker.  It looks odd in the code but at least
> is safe and avoids the ugly \use:n.
>
> Alternatively, if we want maximum speed for the case where the hook exists, we
> could accept to always turn the cs to \relax, something like
>
> [...]
>
> Ok, it's really ugly, I don't like it.  But it should be a bit faster since it
> avoids making the cs from its csname twice, and manipulates fewer tokens as a
> result.

I vote for the \@@_use_end: version.  Hook names probably won't have
/that/ much complicated code, so building the csname twice won't have
that much of an impact on performance, and may save adding an useless
csname to the hash table.

Thanks!

Phelype


More information about the latex3-commits mailing list.