[latex3-commits] [latex3/latex3] main: Avoid constructing a useless quark helper (40b79bcdd)
github at latex-project.org
github at latex-project.org
Tue Feb 27 09:54:21 CET 2024
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/40b79bcdd4fb7778df078d3f4773a227c6608125
>---------------------------------------------------------------
commit 40b79bcdd4fb7778df078d3f4773a227c6608125
Author: Yukai Chou <muzimuzhi at gmail.com>
Date: Tue Feb 20 23:56:03 2024 +0800
Avoid constructing a useless quark helper
Rewrite `\__kernel_quark_new_conditional:Nn` internals to not construct
csnames of form `\__<type>_if_quark_<name>:w` that won't be defined afterwards
in defining n-type if-quark conditionals.
>---------------------------------------------------------------
40b79bcdd4fb7778df078d3f4773a227c6608125
l3kernel/l3quark.dtx | 63 +++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 30 deletions(-)
diff --git a/l3kernel/l3quark.dtx b/l3kernel/l3quark.dtx
index c465fa251..04f6c46be 100644
--- a/l3kernel/l3quark.dtx
+++ b/l3kernel/l3quark.dtx
@@ -820,43 +820,46 @@
% \begin{macro}{
% \@@_new_conditional_n:Nnnn,
% \@@_new_conditional_N:Nnnn,
+% \@@_new_conditional_n_aux:NNNn,
+% \@@_new_conditional_N_aux:NNNn
% }
% These macros implement the two possibilities for branching quark
-% conditionals, passing
-% the right arguments to \cs{@@_new_conditional_aux_do:NNnnn},
-% which defines some auxiliaries and defines the
-% main conditionals.
+% conditionals. To avoid constructing without defining the
+% \cs[no-index]{__\meta{type}_if_quark_\meta{name}:w} helper,
+% \texttt{N}-type function accepts a \cs{prg_do_nothing:} as
+% a placeholder.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_new_conditional_n:Nnnn
- { \@@_new_conditional_aux_do:NNnnn \use_i:nn }
-\cs_new_protected:Npn \@@_new_conditional_N:Nnnn
- { \@@_new_conditional_aux_do:NNnnn \use_ii:nn }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{
-% \@@_new_conditional_aux_do:NNnnn,
-% \@@_new_conditional_define:NNNNn,
-% }
-% Similar to the previous macros, but branching conditionals only
-% require one auxiliary, so we take a shortcut. In
-% \cs{@@_new_conditional_define:NNNNn}, |#4| is \cs{use_i:nn} to
-% define the \texttt{n}-type function (which needs an auxiliary) and
-% is \cs{use_ii:nn} to define the \texttt{N}-type function.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_new_conditional_aux_do:NNnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_new_conditional_n:Nnnn #1 #2 #3
+ {
+ \exp_args:Ncc \@@_new_conditional_n_aux:NNNn
+ { __ #3 _if_quark_ #2 :w } { q__ #3 _ #2 } #1
+ }
+\cs_new_protected:Npn \@@_new_conditional_N:Nnnn #1 #2 #3
{
- \exp_args:Ncc \@@_new_conditional_define:NNNNn
- { __ #4 _if_quark_ #3 :w } { q__ #4 _ #3 } #2 #1
+ \exp_args:NNc \@@_new_conditional_N_aux:NNNn
+ \prg_do_nothing: { q__ #3 _ #2 } #1
}
-\cs_new_protected:Npn \@@_new_conditional_define:NNNNn #1 #2 #3 #4 #5
+\cs_new_protected:Npn \@@_new_conditional_n_aux:NNNn #1 #2 #3 #4
{
- #4 { \cs_gset:Npn #1 ##1 #2 ##2 ? ##3 ?! { ##1 ##2 } } { }
- \exp_args:Nno \use:n { \prg_new_conditional:Npnn #3 ##1 {#5} }
+ \cs_gset:Npn #1 ##1 #2 ##2 ? ##3 ?! { ##1##2 }
+ \prg_new_conditional:Npnn #3 ##1 {#4}
{
- #4 { \@@_if_empty_if:o { #1 {} ##1 {} ?! #2 ??! } }
- { \if_meaning:w #2 ##1 }
- \prg_return_true: \else: \prg_return_false: \fi:
+ \@@_if_empty_if:o { #1 {} ##1 {} ?! #2 ??! }
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
+ }
+\cs_new_protected:Npn \@@_new_conditional_N_aux:NNNn #1 #2 #3 #4
+ {
+ \prg_new_conditional:Npnn #3 ##1 {#4}
+ {
+ \if_meaning:w #2 ##1
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
}
}
% \end{macrocode}
More information about the latex3-commits
mailing list.