[latex3-commits] [l3svn] r6284 - Speed-up \__keys_remove_spaces:n (similar to \zap at spaces)

noreply at latex-project.org noreply at latex-project.org
Tue Nov 17 11:10:56 CET 2015


Author: bruno
Date: 2015-11-17 11:10:56 +0100 (Tue, 17 Nov 2015)
New Revision: 6284

Modified:
   trunk/l3kernel/l3keys.dtx
Log:
Speed-up \__keys_remove_spaces:n (similar to \zap at spaces)

Since this function is used a lot in the keys code, it makes sense to
optimize.  Changing \zap at spaces along the same lines would be too risky as
different braces are lost (not a problem for detokenized keys here).


Modified: trunk/l3kernel/l3keys.dtx
===================================================================
--- trunk/l3kernel/l3keys.dtx	2015-11-17 09:53:24 UTC (rev 6283)
+++ trunk/l3kernel/l3keys.dtx	2015-11-17 10:10:56 UTC (rev 6284)
@@ -2262,20 +2262,18 @@
 % \begin{macro}[EXP, int]{\@@_remove_spaces:n}
 % \begin{macro}[EXP, aux]{\@@_remove_spaces:w}
 %   Removes all spaces from the input which is detokenized as a result.
-%   This function is set up to be fast (and almost identical to \tn{zap at space}
-%   in \LaTeXe{}) as the use case here is tightly defined.
+%   This function has the same effect as \tn{zap at space} in \LaTeXe{}
+%   after applying \cs{tl_to_str:n}.  It is set up to be fast as the
+%   use case here is tightly defined.  The~|?| is only there to allow
+%   for a space after \cs{use_none:nn} responsible for ending the loop.
 %    \begin{macrocode}
 \cs_new:Npn \@@_remove_spaces:n #1
-  { \exp_after:wN \@@_remove_spaces:w \tl_to_str:n {#1} ~ \c_empty_tl }
-\cs_new:Npn \@@_remove_spaces:w #1 ~ #2
   {
-    #1
-    \if_meaning:w #2 \c_empty_tl
-    \else:
-      \exp_after:wN \@@_remove_spaces:w
-    \fi:
-    #2
+    \exp_after:wN \@@_remove_spaces:w \tl_to_str:n {#1}
+    \use_none:nn ? ~
   }
+\cs_new:Npn \@@_remove_spaces:w #1 ~
+  { #1 \@@_remove_spaces:w }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}



More information about the latex3-commits mailing list