[latex3-commits] [git/LaTeX3-latex3-latex3] master: Speed up \exp_args some more and reduce tracingall output by half (2ea08e229)
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/2ea08e229f255c928ce8a2b5344caeafefb5be15
>---------------------------------------------------------------
commit 2ea08e229f255c928ce8a2b5344caeafefb5be15
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Sep 26 00:15:20 2019 +0100
Speed up \exp_args some more and reduce tracingall output by half
Compared to before the last few commits, \exp_args:NXY for various
letters X and Y became around 1.5 to 2 times faster, and more
importantly perhaps we get 2 times fewer lines in the log.
Mumble
>---------------------------------------------------------------
2ea08e229f255c928ce8a2b5344caeafefb5be15
l3kernel/l3expan.dtx | 48 +++++++++++++++++---------------
l3kernel/testfiles/m3expan001.tlg | 2 +-
l3kernel/testfiles/m3expan002.luatex.tlg | 4 +--
l3kernel/testfiles/m3expan002.tlg | 4 +--
4 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/l3kernel/l3expan.dtx b/l3kernel/l3expan.dtx
index 77e34fdb1..c1370e508 100644
--- a/l3kernel/l3expan.dtx
+++ b/l3kernel/l3expan.dtx
@@ -2554,13 +2554,13 @@
% should be protected (done by setting \cs{@@_tmp:w}). Then call
% \cs{@@_generate_internal_variant:NNn} with arguments
% \cs{cs_new_protected:cpn} \cs{use:x} (for protected) or
-% \cs{cs_new:cpn} \cs{use:e} (expandable) and the signature. If |p|
+% \cs{cs_new:cpn} \cs{tex_expanded:D} (expandable) and the signature. If |p|
% appears in the signature, or if the function to be defined is
% expandable and the primitive \tn{expanded} is not available, call
% some fall-back code that just puts the appropriate |\::| commands.
% Otherwise, call \cs{@@_generate_internal_one_go:NNn} to construct
% the \cs[no-index]{exp_args:N\dots} function as a macro taking up to
-% $9$~arguments and expanding them using \cs{use:x} or \cs{use:e}.
+% $9$~arguments and expanding them using \cs{use:x} or \cs{tex_expanded:D}.
% \begin{macrocode}
\cs_new_protected:Npx \@@_generate_internal_variant:n #1
{
@@ -2572,7 +2572,7 @@
\token_to_str:N x \exp_not:N \q_mark
{ }
\cs_new:cpn
- \exp_not:N \use:e
+ \exp_not:N \tex_expanded:D
\exp_not:N \q_stop
{#1}
}
@@ -2612,7 +2612,7 @@
{
\cs_new_protected:Npn \@@_generate_internal_test:Nw ##1
{
- \if_meaning:w \use:e ##1
+ \if_meaning:w \tex_expanded:D ##1
\exp_after:wN \@@_generate_internal_test_aux:w
\exp_after:wN #1
\else:
@@ -2634,28 +2634,32 @@
{
\use_none:n #5
\use_none:n #7
- \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 } } }
- {
- \exp_args:No \@@_generate_internal_loop:nwnnw
- {
- \exp_after:wN
- { \exp:w \exp_args:Nc \exp_end: { exp_not:#5 } { ## #7 } }
- }
- }
+ \cs_if_exist_use:cF { @@_generate_internal_#5:NN }
+ { \@@_generate_internal_other:NN }
+ #5 #7
#7 .
{ #3 #1 } { #4 ## #2 }
#6 ;
}
+\cs_new_protected:Npn \@@_generate_internal_N:NN #1#2
+ { \@@_generate_internal_loop:nwnnw { \exp_not:N ###2 } }
+\cs_new_protected:Npn \@@_generate_internal_c:NN #1#2
+ { \exp_args:No \@@_generate_internal_loop:nwnnw { \exp_not:c {###2} } }
+\cs_new_protected:Npn \@@_generate_internal_n:NN #1#2
+ { \@@_generate_internal_loop:nwnnw { { \exp_not:n {###2} } } }
+\cs_new_protected:Npn \@@_generate_internal_x:NN #1#2
+ { \@@_generate_internal_loop:nwnnw { {###2} } }
+\cs_new_protected:Npn \@@_generate_internal_other:NN #1#2
+ {
+ \exp_args:No \@@_generate_internal_loop:nwnnw
+ {
+ \exp_after:wN
+ {
+ \exp:w \exp_args:NNc \exp_after:wN \exp_end:
+ { exp_not:#1 } {###2}
+ }
+ }
+ }
\cs_new_protected:Npn \@@_generate_internal_end:w #1 . #2#3#4 ; #5 ; #6#7#8
{ #6 { exp_args:N #8 } #3 { #7 {#2} } }
\cs_new_protected:Npn \@@_generate_internal_long:w #1 N #2#3 . #4#5#6#
diff --git a/l3kernel/testfiles/m3expan001.tlg b/l3kernel/testfiles/m3expan001.tlg
index 9ccd768f2..e753ec5d5 100644
--- a/l3kernel/testfiles/m3expan001.tlg
+++ b/l3kernel/testfiles/m3expan001.tlg
@@ -49,7 +49,7 @@ TEST 1: protection
\protected\long macro:->\exp_args:Nfx \foo:nn
\protected\long macro:->\exp_args:Nxf \foo:nn
\protected\long macro:->\exp_args:NfvVonx \bar:nnnnnn
-\protected\long macro:#1#2#3#4#5#6#7->\use:x {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:v {#3}}{\exp_not:V {#4}}{\exp_not:o {#5}}{\exp_not:n {#6}}{#7}}
+\protected\long macro:#1#2#3#4#5#6#7->\use:x {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {\exp:w \__exp_eval_register:c {#3}}}{\__kernel_exp_not:w \exp_after:wN {\exp:w \__exp_eval_register:N #4}}{\__kernel_exp_not:w \exp_after:wN {#5}}{\exp_not:n {#6}}{#7}}
============================================================
============================================================
TEST 2: expansion
diff --git a/l3kernel/testfiles/m3expan002.luatex.tlg b/l3kernel/testfiles/m3expan002.luatex.tlg
index f8579c329..87e4635e8 100644
--- a/l3kernel/testfiles/m3expan002.luatex.tlg
+++ b/l3kernel/testfiles/m3expan002.luatex.tlg
@@ -142,6 +142,6 @@ LaTeX has been asked to create an \exp_args:N... function with signature
'Nabc' but 'a' is not a valid argument specifier.
Defining \exp_args:Nfoo on line ...
Defining \exp_args:Nfox on line ...
-undefined,\long macro:#1#2#3#4->\use:e {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:o {#3}}{\exp_not:o {#4}}},\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:o {#3}}{#4}}
-\long macro:#1#2#3#4->\use:e {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:o {#3}}{\exp_not:o {#4}}},\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:o {#3}}{#4}}
+undefined,\long macro:#1#2#3#4->\tex_expanded:D {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{\__kernel_exp_not:w \exp_after:wN {#4}}},\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{#4}}
+\long macro:#1#2#3#4->\tex_expanded:D {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{\__kernel_exp_not:w \exp_after:wN {#4}}},\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{#4}}
============================================================
diff --git a/l3kernel/testfiles/m3expan002.tlg b/l3kernel/testfiles/m3expan002.tlg
index 8a311211c..87e4635e8 100644
--- a/l3kernel/testfiles/m3expan002.tlg
+++ b/l3kernel/testfiles/m3expan002.tlg
@@ -142,6 +142,6 @@ LaTeX has been asked to create an \exp_args:N... function with signature
'Nabc' but 'a' is not a valid argument specifier.
Defining \exp_args:Nfoo on line ...
Defining \exp_args:Nfox on line ...
-undefined,\long macro:->\::f \::o \::o \::: ,\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:o {#3}}{#4}}
-\long macro:->\::f \::o \::o \::: ,\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\exp_not:f {#2}}{\exp_not:o {#3}}{#4}}
+undefined,\long macro:#1#2#3#4->\tex_expanded:D {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{\__kernel_exp_not:w \exp_after:wN {#4}}},\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{#4}}
+\long macro:#1#2#3#4->\tex_expanded:D {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{\__kernel_exp_not:w \exp_after:wN {#4}}},\protected\long macro:#1#2#3#4->\use:x {\exp_not:N #1{\__kernel_exp_not:w \exp_after:wN {\exp:w \exp_end_continue_f:w #2}}{\__kernel_exp_not:w \exp_after:wN {#3}}{#4}}
============================================================
More information about the latex3-commits
mailing list