[latex3-commits] [git/LaTeX3-latex3-latex3] master: Speed up \exp_args by using the general form for many more signatures (cfc591090)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Sep 26 01:28:56 CEST 2019
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/cfc591090fc81b7be4b2dbf14c37cdafd4d59859
>---------------------------------------------------------------
commit cfc591090fc81b7be4b2dbf14c37cdafd4d59859
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Sun Feb 10 17:55:07 2019 +0100
Speed up \exp_args by using the general form for many more signatures
>---------------------------------------------------------------
cfc591090fc81b7be4b2dbf14c37cdafd4d59859
l3kernel/l3expan.dtx | 204 ++++++++++++++++++++++++++-------------------------
1 file changed, 104 insertions(+), 100 deletions(-)
diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index 9b5bb6687..77e34fdb1 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -1400,99 +1400,13 @@
% \end{macrocode}
% \end{macro}
%
-% \subsection{Definitions with the automated technique}
-% \label{sec:l3expan:gendef}
-%
-% Some of these could be done more efficiently, but the complexity of
-% coding then becomes an issue. Notice that the auto-generated functions
-% actually take no arguments themselves.
-%
% \begin{macro}{\exp_args:Nx}
% \begin{macrocode}
-\cs_new_protected:Npn \exp_args:Nx { \::x \::: }
+\cs_new_protected:Npn \exp_args:Nx #1#2
+ { \use:x { \exp_not:N #1 {#2} } }
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[EXP]
-% {
-% \exp_args:Nnc, \exp_args:Nno, \exp_args:NnV, \exp_args:Nnv, \exp_args:Nne, \exp_args:Nnf,
-% \exp_args:Noc, \exp_args:Noo, \exp_args:Nof,
-% \exp_args:NVo, \exp_args:Nfo, \exp_args:Nff,
-% }
-% \begin{macro}
-% {
-% \exp_args:NNx, \exp_args:Ncx, \exp_args:Nnx,
-% \exp_args:Nox, \exp_args:Nxo, \exp_args:Nxx,
-% }
-% Here are the actual function definitions, using the helper functions
-% above.
-% \begin{macrocode}
-\cs_new:Npn \exp_args:Nnc { \::n \::c \::: }
-\cs_new:Npn \exp_args:Nno { \::n \::o \::: }
-\cs_new:Npn \exp_args:NnV { \::n \::V \::: }
-\cs_new:Npn \exp_args:Nnv { \::n \::v \::: }
-\cs_new:Npn \exp_args:Nne { \::n \::e \::: }
-\cs_new:Npn \exp_args:Nnf { \::n \::f \::: }
-\cs_new:Npn \exp_args:Noc { \::o \::c \::: }
-\cs_new:Npn \exp_args:Noo { \::o \::o \::: }
-\cs_new:Npn \exp_args:Nof { \::o \::f \::: }
-\cs_new:Npn \exp_args:NVo { \::V \::o \::: }
-\cs_new:Npn \exp_args:Nfo { \::f \::o \::: }
-\cs_new:Npn \exp_args:Nff { \::f \::f \::: }
-\cs_new_protected:Npn \exp_args:NNx { \::N \::x \::: }
-\cs_new_protected:Npn \exp_args:Ncx { \::c \::x \::: }
-\cs_new_protected:Npn \exp_args:Nnx { \::n \::x \::: }
-\cs_new_protected:Npn \exp_args:Nox { \::o \::x \::: }
-\cs_new_protected:Npn \exp_args:Nxo { \::x \::o \::: }
-\cs_new_protected:Npn \exp_args:Nxx { \::x \::x \::: }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}[EXP]
-% {
-% \exp_args:NNNv, \exp_args:NNcf,
-% \exp_args:NNno, \exp_args:NNnV, \exp_args:NNoo, \exp_args:NNVV,
-% \exp_args:Ncno, \exp_args:NcnV, \exp_args:Ncoo, \exp_args:NcVV,
-% \exp_args:Nnnc, \exp_args:Nnno, \exp_args:Nnnf, \exp_args:Nnff,
-% \exp_args:Nooo, \exp_args:Noof, \exp_args:Nffo,
-% }
-% \begin{macro}
-% {
-% \exp_args:NNNx, \exp_args:NNnx, \exp_args:NNox,
-% \exp_args:Nccx, \exp_args:Ncnx,
-% \exp_args:Nnnx, \exp_args:Nnox, \exp_args:Noox,
-% }
-% \begin{macrocode}
-\cs_new:Npn \exp_args:NNNv { \::N \::N \::v \::: }
-\cs_new:Npn \exp_args:NNcf { \::N \::c \::f \::: }
-\cs_new:Npn \exp_args:NNno { \::N \::n \::o \::: }
-\cs_new:Npn \exp_args:NNnV { \::N \::n \::V \::: }
-\cs_new:Npn \exp_args:NNoo { \::N \::o \::o \::: }
-\cs_new:Npn \exp_args:NNVV { \::N \::V \::V \::: }
-\cs_new:Npn \exp_args:Ncno { \::c \::n \::o \::: }
-\cs_new:Npn \exp_args:NcnV { \::c \::n \::V \::: }
-\cs_new:Npn \exp_args:Ncoo { \::c \::o \::o \::: }
-\cs_new:Npn \exp_args:NcVV { \::c \::V \::V \::: }
-\cs_new:Npn \exp_args:Nnnc { \::n \::n \::c \::: }
-\cs_new:Npn \exp_args:Nnno { \::n \::n \::o \::: }
-\cs_new:Npn \exp_args:Nnnf { \::n \::n \::f \::: }
-\cs_new:Npn \exp_args:Nnff { \::n \::f \::f \::: }
-\cs_new:Npn \exp_args:Nooo { \::o \::o \::o \::: }
-\cs_new:Npn \exp_args:Noof { \::o \::o \::f \::: }
-\cs_new:Npn \exp_args:Nffo { \::f \::f \::o \::: }
-\cs_new_protected:Npn \exp_args:NNNx { \::N \::N \::x \::: }
-\cs_new_protected:Npn \exp_args:NNnx { \::N \::n \::x \::: }
-\cs_new_protected:Npn \exp_args:NNox { \::N \::o \::x \::: }
-\cs_new_protected:Npn \exp_args:Nnnx { \::n \::n \::x \::: }
-\cs_new_protected:Npn \exp_args:Nnox { \::n \::o \::x \::: }
-\cs_new_protected:Npn \exp_args:Nccx { \::c \::c \::x \::: }
-\cs_new_protected:Npn \exp_args:Ncnx { \::c \::n \::x \::: }
-\cs_new_protected:Npn \exp_args:Noox { \::o \::o \::x \::: }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
% \subsection{Last-unbraced versions}
%
% \begin{macro}[EXP]{\@@_arg_last_unbraced:nn}
@@ -2720,16 +2634,14 @@
{
\use_none:n #5
\use_none:n #7
- \if_case:w
- \if:w N #5 1 ~ \fi:
- \if:w c #5 2 ~ \fi:
- \if:w x #5 3 ~ \fi:
- 4 ~
- \or: \exp_after:wN \use_i:nnnn
- \or: \exp_after:wN \use_ii:nnnn
- \or: \exp_after:wN \use_iii:nnnn
- \or: \exp_after:wN \use_iv:nnnn
- \fi:
+ \cs:w
+ use_
+ \if:w N #5 i \else:
+ \if:w c #5 ii \else:
+ \if:w x #5 iii \else:
+ iv \fi: \fi: \fi:
+ :nnnn
+ \cs_end:
{ \@@_generate_internal_loop:nwnnw { \exp_not:N ## #7 } }
{ \@@_generate_internal_loop:nwnnw { \exp_not:c { ## #7 } } }
{ \@@_generate_internal_loop:nwnnw { { ## #7 } } }
@@ -2831,8 +2743,7 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\exp_args_generate:n, \@@_args_generate:Nn}
-% \begin{macro}[EXP]{\@@_args_generate:n}
+% \begin{macro}{\exp_args_generate:n}
% This function is not used in the kernel hence we can use functions
% that are defined in later modules. It also does not need to be fast
% so use inline mappings. For each requested variant we check that
@@ -2857,6 +2768,99 @@
}
% \end{macrocode}
% \end{macro}
+%
+% \subsection{Definitions with the automated technique}
+% \label{sec:l3expan:gendef}
+%
+% Some of these could be done more efficiently, but the complexity of
+% coding then becomes an issue. Notice that the auto-generated functions
+% actually take no arguments themselves.
+%
+% \begin{macro}[EXP]
+% {
+% \exp_args:Nnc, \exp_args:Nno, \exp_args:NnV, \exp_args:Nnv, \exp_args:Nne, \exp_args:Nnf,
+% \exp_args:Noc, \exp_args:Noo, \exp_args:Nof,
+% \exp_args:NVo, \exp_args:Nfo, \exp_args:Nff,
+% }
+% \begin{macro}
+% {
+% \exp_args:NNx, \exp_args:Ncx, \exp_args:Nnx,
+% \exp_args:Nox, \exp_args:Nxo, \exp_args:Nxx,
+% }
+% Here are the actual function definitions, using the helper
+% functions above. The group is used because
+% \cs{@@_generate_internal_variant:n} redefines \cs{@@_tmp:w} locally.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_tmp:w #1
+ {
+ \group_begin:
+ \exp_args:No \@@_generate_internal_variant:n
+ { \tl_to_str:n {#1} }
+ \group_end:
+ }
+\@@_tmp:w { nc }
+\@@_tmp:w { no }
+\@@_tmp:w { nV }
+\@@_tmp:w { nv }
+\@@_tmp:w { ne }
+\@@_tmp:w { nf }
+\@@_tmp:w { oc }
+\@@_tmp:w { oo }
+\@@_tmp:w { of }
+\@@_tmp:w { Vo }
+\@@_tmp:w { fo }
+\@@_tmp:w { ff }
+\@@_tmp:w { Nx }
+\@@_tmp:w { cx }
+\@@_tmp:w { nx }
+\@@_tmp:w { ox }
+\@@_tmp:w { xo }
+\@@_tmp:w { xx }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[EXP]
+% {
+% \exp_args:NNcf,
+% \exp_args:NNno, \exp_args:NNnV, \exp_args:NNoo, \exp_args:NNVV,
+% \exp_args:Ncno, \exp_args:NcnV, \exp_args:Ncoo, \exp_args:NcVV,
+% \exp_args:Nnnc, \exp_args:Nnno, \exp_args:Nnnf, \exp_args:Nnff,
+% \exp_args:Nooo, \exp_args:Noof, \exp_args:Nffo,
+% }
+% \begin{macro}
+% {
+% \exp_args:NNNx, \exp_args:NNnx, \exp_args:NNox,
+% \exp_args:Nccx, \exp_args:Ncnx,
+% \exp_args:Nnnx, \exp_args:Nnox, \exp_args:Noox,
+% }
+% \begin{macrocode}
+\@@_tmp:w { Ncf }
+\@@_tmp:w { Nno }
+\@@_tmp:w { NnV }
+\@@_tmp:w { Noo }
+\@@_tmp:w { NVV }
+\@@_tmp:w { cno }
+\@@_tmp:w { cnV }
+\@@_tmp:w { coo }
+\@@_tmp:w { cVV }
+\@@_tmp:w { nnc }
+\@@_tmp:w { nno }
+\@@_tmp:w { nnf }
+\@@_tmp:w { nff }
+\@@_tmp:w { ooo }
+\@@_tmp:w { oof }
+\@@_tmp:w { ffo }
+\@@_tmp:w { NNx }
+\@@_tmp:w { Nnx }
+\@@_tmp:w { Nox }
+\@@_tmp:w { nnx }
+\@@_tmp:w { nox }
+\@@_tmp:w { ccx }
+\@@_tmp:w { cnx }
+\@@_tmp:w { oox }
+% \end{macrocode}
+% \end{macro}
% \end{macro}
%
% \begin{macrocode}
More information about the latex3-commits
mailing list