[latex3-commits] [git/LaTeX3-latex3-latex3] main: slight performance tweaks (88927e5cc)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jan 10 14:45:55 CET 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/88927e5ccfdc3192ddc7e3d34a69320c349c89c4

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

commit 88927e5ccfdc3192ddc7e3d34a69320c349c89c4
Author: Jonathan Spratte <jspratte at yahoo.de>
Date:   Tue Nov 17 01:17:37 2020 +0100

    slight performance tweaks


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

88927e5ccfdc3192ddc7e3d34a69320c349c89c4
 l3kernel/l3prop.dtx | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/l3kernel/l3prop.dtx b/l3kernel/l3prop.dtx
index 89593da0d..fb2c91ad9 100644
--- a/l3kernel/l3prop.dtx
+++ b/l3kernel/l3prop.dtx
@@ -1072,7 +1072,7 @@
 %
 % \begin{macro}[EXP]{\prop_to_keyval:N}
 % \begin{macro}[EXP]
-%   {\@@_to_keyval_aux:w, \@@_to_keyval_aux:nn, % \@@_to_keyval_aux:nnw}
+%   {\@@_to_keyval_exp_after:wN, \@@_to_keyval_aux:nn, \@@_to_keyval_aux:nnw}
 %   Each property name and value pair will be returned in the form
 %   \meta{name}\verb*|= |\marg{value}. As one of the main use cases for this
 %   macro is to pass the \meta{property list} on to a key--value parser, we have
@@ -1091,11 +1091,9 @@
 %   The variant using \cs{tex_expanded:D} can just iterate over the
 %   \meta{property list} and remove the leading comma afterwards. Only the value
 %   has to be protected in \cs{exp_not:n} as the property name is always a
-%   string. In order to not have to read the contents of the
-%   \meta{property list} more often than necessary, this version uses an
-%   unmatched closing brace to mark the end of the result. Once we're done we
-%   just remove the leading comma and leave an unmatched opening brace in the
-%   input stream so that \cs{__kernel_exp_not:w} grabs its argument.
+%   string. After the loop the leading comma is removed by \cs{use_none:n} and
+%   afterwards \cs{__kernel_exp_not:w} eventually finds the opening brace of its
+%   argument.
 %    \begin{macrocode}
     \cs_new:Npn \prop_to_keyval:N #1
       {
@@ -1103,25 +1101,27 @@
           \prop_if_empty:NTF #1
             { {} }
             {
-              \if_false: { \fi:
-                \exp_after:wN \@@_to_keyval_aux:w
+              \exp_after:wN \exp_after:wN \exp_after:wN
+              {
                 \tex_expanded:D
-                  { \prop_map_function:NN #1 \@@_to_keyval_aux:nn }
+                  {
+                    \__kernel_exp_not:w { \use_none:n }
+                    \prop_map_function:NN #1 \@@_to_keyval_aux:nn
+                  }
               }
             }
       }
-    \cs_new:Npn \@@_to_keyval_aux:w ,
-      { \exp_after:wN { \if_false: } \fi: }
     \cs_new:Npn \@@_to_keyval_aux:nn #1#2
       { , #1 =~ { \exp_not:n {#2} } }
   }
 %    \end{macrocode}
 %   The other variant will iterate over the \meta{property list} and has to
-%   output the result in a group after a marker. As a result this is
-%   considerably slower than the \cs{tex_expanded:D} using variant as it has to
-%   read the entire contents of the \meta{property list} for each item.
-%   After the loop the marker is removed and the leading comma is gobbled by
-%   \cs{use_none:n}, leaving the result as the argument to
+%   output the result in a group after the marker
+%   \cs{@@_to_keyval_exp_after:wN}. As a result this is considerably slower than
+%   the \cs{tex_expanded:D} using variant as it has to read the entire contents
+%   of the \meta{property list} for each item.  Since the marker is just
+%   \cs{exp_after:wN} with another name, after the loop the leading comma is
+%   gobbled by \cs{use_none:n}, leaving the result as the argument to
 %   \cs{__kernel_exp_not:w}.
 %    \begin{macrocode}
   {
@@ -1132,13 +1132,12 @@
             { {} }
             {
               \prop_map_function:NN #1 \@@_to_keyval_aux:nnw
-              \@@_to_keyval_aux:w
-              \s_@@_mark { \use_none:n }
+              \@@_to_keyval_exp_after:wN { \use_none:n }
             }
       }
-    \cs_new:Npn \@@_to_keyval_aux:w \s_@@_mark { \exp_after:wN }
-    \cs_new:Npn \@@_to_keyval_aux:nnw #1#2#3 \s_@@_mark #4
-      { #3 \s_@@_mark { #4 , #1 =~ {#2} } }
+    \cs_new_eq:NN \@@_to_keyval_exp_after:wN \exp_after:wN
+    \cs_new:Npn \@@_to_keyval_aux:nnw #1#2#3 \@@_to_keyval_exp_after:wN #4
+      { #3 \@@_to_keyval_exp_after:wN { #4 , #1 =~ {#2} } }
   }
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.