[latex3-commits] [git/LaTeX3-latex3-latex3] master: faster tl_if_head_is_space:n (1c90496e5)

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/1c90496e59c7b0d98bd1d983966ae9d550e2f8a4

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

commit 1c90496e59c7b0d98bd1d983966ae9d550e2f8a4
Author: Jonathan Spratte <jspratte at yahoo.de>
Date:   Sun Aug 9 18:40:48 2020 +0200

    faster tl_if_head_is_space:n


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

1c90496e59c7b0d98bd1d983966ae9d550e2f8a4
 l3kernel/l3tl.dtx | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/l3kernel/l3tl.dtx b/l3kernel/l3tl.dtx
index ae9efc6ba..531fdb943 100644
--- a/l3kernel/l3tl.dtx
+++ b/l3kernel/l3tl.dtx
@@ -3161,9 +3161,9 @@
 % \begin{macro}[EXP,pTF]{\tl_if_head_is_space:n}
 % \begin{macro}[EXP]{\@@_if_head_is_space:w}
 %   The auxiliary's argument is all that is before the first explicit
-%   space in |?#1?~|.  If that is a single~|?| the test yields
-%   \texttt{true}.  Otherwise, that is more than one token, and the test
-%   yields \texttt{false}.  The work is done within braces (with an
+%   space in |\prg_do_nothing:#1?~|.  If that is a single~|\prg_do_nothing:| the
+%   test yields \texttt{true}.  Otherwise, that is more than one token, and the
+%   test yields \texttt{false}.  The work is done within braces (with an
 %   |\if_false: { \fi: ... }| construction) both to hide potential
 %   alignment tab characters from \TeX{} in a table, and to allow for
 %   removing what remains of the token list after its first space.  The
@@ -3174,14 +3174,22 @@
 \prg_new_conditional:Npnn \tl_if_head_is_space:n #1 { p , T , F , TF }
   {
     \exp:w \if_false: { \fi:
-      \@@_if_head_is_space:w ? #1 ? ~ }
+      \@@_if_head_is_space:w \prg_do_nothing: #1 ? ~ }
   }
 \cs_new:Npn \@@_if_head_is_space:w #1 ~
   {
-    \tl_if_empty:oTF { \use_none:n #1 }
-      { \exp_after:wN \exp_end: \exp_after:wN \prg_return_true: }
-      { \exp_after:wN \exp_end: \exp_after:wN \prg_return_false: }
-    \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi:
+    \tl_if_empty:oTF { #1 }
+      { \exp_after:wN \@@_if_head_is_space_true:n }
+      { \exp_after:wN \@@_if_head_is_space_false:n }
+    \exp_after:wN { \if_false: } \fi:
+  }
+\cs_new:Npn \@@_if_head_is_space_true:n #1
+  {
+    \exp_end: \prg_return_true:
+  }
+\cs_new:Npn \@@_if_head_is_space_false:n #1
+  {
+    \exp_end: \prg_return_false:
   }
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.