[latex3-commits] [git/LaTeX3-latex3-latex3] master: Speed up \seq_map_function:NN (1d788dd)

Bruno Le Floch bruno at le-floch.fr
Sun Apr 29 16:31:14 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/1d788ddb226204d0b9f07829482201f8975882b6

>---------------------------------------------------------------

commit 1d788ddb226204d0b9f07829482201f8975882b6
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sun Apr 29 10:31:14 2018 -0400

    Speed up \seq_map_function:NN


>---------------------------------------------------------------

1d788ddb226204d0b9f07829482201f8975882b6
 l3kernel/l3seq.dtx                      |   20 ++++++++++----------
 l3kernel/testfiles/m3expl001.luatex.tlg |    2 +-
 l3kernel/testfiles/m3expl001.ptex.tlg   |    2 +-
 l3kernel/testfiles/m3expl001.tlg        |    2 +-
 l3kernel/testfiles/m3expl001.uptex.tlg  |    2 +-
 l3kernel/testfiles/m3expl001.xetex.tlg  |    2 +-
 l3kernel/testfiles/m3expl003.luatex.tlg |    2 +-
 l3kernel/testfiles/m3expl003.ptex.tlg   |    2 +-
 l3kernel/testfiles/m3expl003.tlg        |    2 +-
 l3kernel/testfiles/m3expl003.uptex.tlg  |    2 +-
 l3kernel/testfiles/m3expl003.xetex.tlg  |    2 +-
 11 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/l3kernel/l3seq.dtx b/l3kernel/l3seq.dtx
index 9527b18..cd6ae0a 100644
--- a/l3kernel/l3seq.dtx
+++ b/l3kernel/l3seq.dtx
@@ -1725,26 +1725,26 @@
 % \UnitTested
 % \begin{macro}[rEXP]{\@@_map_function:NNn}
 %   The idea here is to apply the code of |#2| to each item in the
-%   sequence without altering the definition of \cs{@@_item:n}. This
-%   is done as by noting that every odd token in the sequence must be
-%   \cs{@@_item:n}, which can be gobbled by \cs{use_none:n}. At the end of
-%   the loop, |#2| is instead |? \seq_map_break:|, which therefore breaks the
-%   loop without needing to do a (relatively-expensive) quark test.
+%   sequence without altering the definition of \cs{@@_item:n}.  The
+%   argument delimited by \cs{@@_item:n} is almost always empty, except
+%   at the end of the loop where it is \cs{prg_break:}.  This allows to
+%   break the loop without needing to do a (relatively-expensive) quark
+%   test.
 %    \begin{macrocode}
 \cs_new:Npn \seq_map_function:NN #1#2
   {
     \exp_after:wN \use_i_ii:nnn
-    \exp_after:wN \@@_map_function:NNn
+    \exp_after:wN \@@_map_function:Nw
     \exp_after:wN #2
     #1
-    { ? \seq_map_break: } { }
+    \prg_break: \@@_item:n { } \prg_break_point:
     \prg_break_point:Nn \seq_map_break: { }
   }
-\cs_new:Npn \@@_map_function:NNn #1#2#3
+\cs_new:Npn \@@_map_function:Nw #1#2 \@@_item:n #3
   {
-    \use_none:n #2
+    #2
     #1 {#3}
-    \@@_map_function:NNn #1
+    \@@_map_function:Nw #1
   }
 \cs_generate_variant:Nn \seq_map_function:NN { c }
 %    \end{macrocode}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index ad3594c..b7baf97 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -1163,7 +1163,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index b41a8ae..7defa58 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index c8830aa..3abbb76 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 89e01d7..51e3961 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 59143e1..be2ca19 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index ad3594c..b7baf97 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -1163,7 +1163,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index b41a8ae..7defa58 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index c8830aa..3abbb76 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 89e01d7..51e3961 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 59143e1..be2ca19 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -1161,7 +1161,7 @@ Defining \seq_item:cn on line ...
 Defining \seq_map_break: on line ...
 Defining \seq_map_break:n on line ...
 Defining \seq_map_function:NN on line ...
-Defining \__seq_map_function:NNn on line ...
+Defining \__seq_map_function:Nw on line ...
 Defining \seq_map_function:cN on line ...
 Defining \__seq_push_item_def:n on line ...
 Defining \__seq_push_item_def:x on line ...





More information about the latex3-commits mailing list