[latex3-commits] [git/LaTeX3-latex3-latex3] master: slightly faster tl_trim_spaces:n (5c3f4ff31)

Bruno Le Floch blflatex at gmail.com
Tue Oct 27 09:11:58 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/5c3f4ff31ee97f4ef81872ddbc7b6f2eb1fd5cff

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

commit 5c3f4ff31ee97f4ef81872ddbc7b6f2eb1fd5cff
Author: Jonathan Spratte <jspratte at yahoo.de>
Date:   Sun Aug 9 20:09:26 2020 +0200

    slightly faster tl_trim_spaces:n


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

5c3f4ff31ee97f4ef81872ddbc7b6f2eb1fd5cff
 l3kernel/l3tl.dtx | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/l3kernel/l3tl.dtx b/l3kernel/l3tl.dtx
index 531fdb943..59a18e5b0 100644
--- a/l3kernel/l3tl.dtx
+++ b/l3kernel/l3tl.dtx
@@ -2641,17 +2641,18 @@
 %   }
 %   Trimming spaces from around the input is deferred to an internal
 %   function whose first argument is the token list to trim, augmented
-%   by an initial \cs{s_@@_mark}, and whose second argument is a
+%   by an initial \cs{@@_trim_mark:}, and whose second argument is a
 %   \meta{continuation}, which receives as a braced argument
-%   \cs{use_none:n} \cs{s_@@_mark} \meta{trimmed token list}.  In the case
+%   \cs{@@_trim_mark:} \meta{trimmed token list}.  The control sequence
+%   \cs{@@_trim_mark:} expands to nothing in a single expansion.  In the case
 %   at hand, we take \cs{exp_not:o} as our continuation, so that space
 %   trimming behaves correctly within an \texttt{x}-type expansion.
 %    \begin{macrocode}
 \cs_new:Npn \tl_trim_spaces:n #1
-  { \@@_trim_spaces:nn { \s_@@_mark #1 } \exp_not:o }
+  { \@@_trim_spaces:nn { \@@_trim_mark: #1 } \exp_not:o }
 \cs_generate_variant:Nn \tl_trim_spaces:n { o }
 \cs_new:Npn \tl_trim_spaces_apply:nN #1#2
-  { \@@_trim_spaces:nn { \s_@@_mark #1 } { \exp_args:No #2 } }
+  { \@@_trim_spaces:nn { \@@_trim_mark: #1 } { \exp_args:No #2 } }
 \cs_generate_variant:Nn \tl_trim_spaces_apply:nN { o }
 \cs_new_protected:Npn \tl_trim_spaces:N #1
   { \tl_set:Nx #1 { \exp_args:No \tl_trim_spaces:n {#1} } }
@@ -2679,7 +2680,7 @@
 %   \cs{@@_trim_spaces_auxii:w}. This hands the relevant tokens to the
 %   loop \cs{@@_trim_spaces_auxiii:w}, responsible for trimming
 %   trailing spaces. The end is reached when \verb*+ + \cs{s_@@_nil}
-%   matches the one present in the definition of \cs{tl_trim_spacs:n}.
+%   matches the one present in the definition of \cs{tl_trim_spaces:n}.
 %   Then \cs{@@_trim_spaces_auxiv:w} puts the token list into a group,
 %   with \cs{use_none:n} placed there to gobble a lingering \cs{s_@@_mark},
 %   and feeds this to the \meta{continuation}.
@@ -2691,23 +2692,24 @@
         \@@_trim_spaces_auxi:w
           ##1
           \s_@@_nil
-          \s_@@_mark #1 { }
-          \s_@@_mark \@@_trim_spaces_auxii:w
+          \@@_trim_mark: #1 { }
+          \@@_trim_mark: \@@_trim_spaces_auxii:w
           \@@_trim_spaces_auxiii:w
           #1 \s_@@_nil
           \@@_trim_spaces_auxiv:w
         \s_@@_stop
       }
-    \cs_new:Npn \@@_trim_spaces_auxi:w ##1 \s_@@_mark #1 ##2 \s_@@_mark ##3
+    \cs_new:Npn
+        \@@_trim_spaces_auxi:w ##1 \@@_trim_mark: #1 ##2 \@@_trim_mark: ##3
       {
         ##3
         \@@_trim_spaces_auxi:w
-        \s_@@_mark
+        \@@_trim_mark:
         ##2
-        \s_@@_mark #1 {##1}
+        \@@_trim_mark: #1 {##1}
       }
     \cs_new:Npn \@@_trim_spaces_auxii:w
-        \@@_trim_spaces_auxi:w \s_@@_mark \s_@@_mark ##1
+        \@@_trim_spaces_auxi:w \@@_trim_mark: \@@_trim_mark: ##1
       {
         \@@_trim_spaces_auxiii:w
         ##1
@@ -2719,7 +2721,8 @@
         \@@_trim_spaces_auxiii:w
       }
     \cs_new:Npn \@@_trim_spaces_auxiv:w ##1 \s_@@_nil ##2 \s_@@_stop ##3
-      { ##3 { \use_none:n ##1 } }
+      { ##3 { ##1 } }
+    \cs_new:Npn \@@_trim_mark: {}
   }
 \@@_tmp:w { ~ }
 %    \end{macrocode}





More information about the latex3-commits mailing list.