[latex3-commits] [latex3/latex3] main: Speed up cs_undefine:c (8ea2eb77e)
github at latex-project.org
github at latex-project.org
Thu Jan 11 23:42:37 CET 2024
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/8ea2eb77e8c8cb66cde4fdb669fbaadd3378c44d
>---------------------------------------------------------------
commit 8ea2eb77e8c8cb66cde4fdb669fbaadd3378c44d
Author: Bruno Le Floch <blflatex at gmail.com>
Date: Thu Jan 11 23:40:23 2024 +0100
Speed up cs_undefine:c
This is an unimportant but easy 5% speed-up.
>---------------------------------------------------------------
8ea2eb77e8c8cb66cde4fdb669fbaadd3378c44d
l3kernel/l3basics.dtx | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/l3kernel/l3basics.dtx b/l3kernel/l3basics.dtx
index 761aa46a7..88bee3172 100644
--- a/l3kernel/l3basics.dtx
+++ b/l3kernel/l3basics.dtx
@@ -2824,17 +2824,18 @@
% The \texttt{c} variant is careful not to add the control sequence
% to the hash table if it isn't there yet, and it also avoids nesting
% \TeX{} conditionals in case |#1| is unbalanced in this matter.
+% We optimize the case where the command exists by reducing as much as
+% possible the tokens in the conditional.
% \begin{macrocode}
\cs_new_protected:Npn \cs_undefine:N #1
{ \cs_gset_eq:NN #1 \tex_undefined:D }
\cs_new_protected:Npn \cs_undefine:c #1
{
\if_cs_exist:w #1 \cs_end:
- \exp_after:wN \use:n
\else:
- \exp_after:wN \use_none:n
+ \use_i:nnnn
\fi:
- { \cs_gset_eq:cN {#1} \tex_undefined:D }
+ \exp_args:Nc \cs_undefine:N {#1}
}
% \end{macrocode}
% \end{macro}
More information about the latex3-commits
mailing list.