[latex3-commits] [git/LaTeX3-latex3-latex3] main: Prefer scan-marks to quarks in l3clist (and speed up some n-type functions) (b997f015d)
Bruno Le Floch
blflatex at gmail.com
Sat May 15 17:21:44 CEST 2021
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/b997f015db02547f580eca5c0a56e0a0e47e0a5d
>---------------------------------------------------------------
commit b997f015db02547f580eca5c0a56e0a0e47e0a5d
Author: Bruno Le Floch <blflatex at gmail.com>
Date: Sat May 15 17:21:17 2021 +0200
Prefer scan-marks to quarks in l3clist (and speed up some n-type functions)
>---------------------------------------------------------------
b997f015db02547f580eca5c0a56e0a0e47e0a5d
l3kernel/l3clist.dtx | 65 ++++++++++++++++++++++------------------------------
1 file changed, 27 insertions(+), 38 deletions(-)
diff --git a/l3kernel/l3clist.dtx b/l3kernel/l3clist.dtx
index 970aed1c7..f0e89abfe 100644
--- a/l3kernel/l3clist.dtx
+++ b/l3kernel/l3clist.dtx
@@ -846,22 +846,6 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{variable}{\q_@@_recursion_tail,\q_@@_recursion_stop}
-% Internal recursion quarks.
-% \begin{macrocode}
-\quark_new:N \q_@@_recursion_tail
-\quark_new:N \q_@@_recursion_stop
-% \end{macrocode}
-% \end{variable}
-%
-% \begin{macro}[EXP]{\@@_if_recursion_tail_break:nN,\@@_if_recursion_tail_stop:n}
-% Functions to query recursion quarks.
-% \begin{macrocode}
-\__kernel_quark_new_test:N \@@_if_recursion_tail_break:nN
-\__kernel_quark_new_test:N \@@_if_recursion_tail_stop:n
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\@@_tmp:w}
% A temporary function for various purposes.
% \begin{macrocode}
@@ -903,11 +887,11 @@
{
\exp_after:wN \@@_sanitize:Nn \exp_after:wN \c_empty_tl
\exp:w \@@_trim_next:w \prg_do_nothing:
- #1 , \q_@@_recursion_tail , \q_@@_recursion_stop
+ #1 , \s_@@_stop \prg_break: , \prg_break_point:
}
\cs_new:Npn \@@_sanitize:Nn #1#2
{
- \@@_if_recursion_tail_stop:n {#2}
+ \@@_use_none_delimit_by_s_stop:w #2 \s_@@_stop
#1 \@@_wrap_item:w #2 ,
\exp_after:wN \@@_sanitize:Nn \exp_after:wN ,
\exp:w \@@_trim_next:w \prg_do_nothing:
@@ -1722,12 +1706,13 @@
\cs_new:Npn \clist_map_function:nN #1#2
{
\exp_after:wN \@@_map_function_n:Nn \exp_after:wN #2
- \exp:w \@@_trim_next:w \prg_do_nothing: #1 , \q_@@_recursion_tail ,
+ \exp:w \@@_trim_next:w \prg_do_nothing: #1 ,
+ \s_@@_stop \clist_map_break: ,
\prg_break_point:Nn \clist_map_break: { }
}
\cs_new:Npn \@@_map_function_n:Nn #1 #2
{
- \@@_if_recursion_tail_break:nN {#2} \clist_map_break:
+ \@@_use_none_delimit_by_s_stop:w #2 \s_@@_stop
\@@_map_unbrace:wn #2 , #1
\exp_after:wN \@@_map_function_n:Nn \exp_after:wN #1
\exp:w \@@_trim_next:w \prg_do_nothing:
@@ -1847,14 +1832,14 @@
\cs_new:Npn \clist_map_tokens:nn #1#2
{
\@@_map_tokens_n:nw {#2}
- \prg_do_nothing: #1 , \q_@@_recursion_tail ,
+ \prg_do_nothing: #1 , \s_@@_stop \clist_map_break: ,
\prg_break_point:Nn \clist_map_break: { }
}
\cs_new:Npn \@@_map_tokens_n:nw #1#2 ,
{
\tl_if_empty:oF { \use_none:nn #2 ? }
{
- \exp_args:No \@@_if_recursion_tail_break:nN {#2} \clist_map_break:
+ \@@_use_none_delimit_by_s_stop:w #2 \s_@@_stop
\tl_trim_spaces_apply:oN {#2} \use_ii_i:nn
\@@_map_unbrace:wn , {#1}
}
@@ -1893,22 +1878,26 @@
}
}
\cs_generate_variant:Nn \clist_count:N { c }
-\cs_new:Npx \clist_count:n #1
+\cs_new:Npn \@@_count:n #1 { + 1 }
+\cs_set_protected:Npn \@@_tmp:w #1
{
- \exp_not:N \int_eval:n
+ \cs_new:Npn \clist_count:n ##1
{
- 0
- \exp_not:N \@@_count:w \c_space_tl
- #1 \exp_not:n { , \q_@@_recursion_tail , \q_@@_recursion_stop }
+ \int_eval:n
+ {
+ 0
+ \@@_count:w #1
+ ##1 , \s_@@_stop \prg_break: , \prg_break_point:
+ }
+ }
+ \cs_new:Npn \@@_count:w ##1 ,
+ {
+ \@@_use_none_delimit_by_s_stop:w ##1 \s_@@_stop
+ \tl_if_blank:nF {##1} { + 1 }
+ \@@_count:w #1
}
}
-\cs_new:Npn \@@_count:n #1 { + 1 }
-\cs_new:Npx \@@_count:w #1 ,
- {
- \exp_not:n { \exp_args:Nf \@@_if_recursion_tail_stop:n } {#1}
- \exp_not:N \tl_if_blank:nF {#1} { + 1 }
- \exp_not:N \@@_count:w \c_space_tl
- }
+\exp_args:No \@@_tmp:w \c_space_tl
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1931,15 +1920,15 @@
% quarks), 5: the rest of the comma list, 6: a \meta{continuation}
% function (\texttt{use_ii} or \texttt{use_iii} with its
% \meta{separator} argument), 7: junk, and 8: the temporary result,
-% which is built in a brace group following \cs{q_@@_stop}. The
+% which is built in a brace group following \cs{s_@@_stop}. The
% \meta{separator} and the first of the three items are placed in the
% result, then we use the \meta{continuation}, placing the remaining
% two items after it. When we begin this loop, the three items really
-% belong to the comma list, the first \cs{q_@@_mark} is taken as a
+% belong to the comma list, the first \cs{s_@@_mark} is taken as a
% delimiter to the \texttt{use_ii} function, and the continuation is
% \texttt{use_ii} itself. When we reach the last two items of the
-% original token list, \cs{q_@@_mark} is taken as a third item, and now
-% the second \cs{q_@@_mark} serves as a delimiter to \texttt{use_ii},
+% original token list, \cs{s_@@_mark} is taken as a third item, and now
+% the second \cs{s_@@_mark} serves as a delimiter to \texttt{use_ii},
% switching to the other \meta{continuation}, \texttt{use_iii}, which
% uses the \meta{separator between final two}.
% \begin{macrocode}
More information about the latex3-commits
mailing list.