[latex3-commits] [latex3/latex3] main: Replace \seq_set_from_function:NnN use in l3regex (cb4e72bbd)

github at latex-project.org github at latex-project.org
Fri May 5 12:50:29 CEST 2023


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

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

commit cb4e72bbdbc464c43a07e98aeda9874d39b4632d
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri May 5 11:50:29 2023 +0100

    Replace \seq_set_from_function:NnN use in l3regex
    
    Slower but avoids this to-be-removed function.


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

cb4e72bbdbc464c43a07e98aeda9874d39b4632d
 l3kernel/l3regex.dtx | 54 +++++++++++++++++++++-------------------------------
 1 file changed, 22 insertions(+), 32 deletions(-)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 7e5734599..4599b9975 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -6938,6 +6938,9 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_group_end_extract_seq:N}
+% \begin{macro}{\@@_extract_seq:N}
+% \begin{macro}{\@@_extract_seq:NNn}
+% \begin{macro}{\@@_extract_seq_loop:Nw}
 %   The end-points of submatches are stored as entries of two arrays
 %   from \cs{l_@@_min_submatch_int} to \cs{l_@@_submatch_int}
 %   (exclusive). Extract the relevant ranges into \cs{g_@@_internal_tl},
@@ -6977,12 +6980,28 @@
             { \int_use:N \l_@@_added_end_int }
         }
     \group_end:
-    \cs_set_eq:NN \@@_tmp:w \@@_extract_map_loop:w
-    \seq_set_from_function:NnN #1
-      { \@@_extract_map:N } \exp_not:n
+    \@@_extract_seq:N #1
+  }
+\cs_gset_protected:Npn \@@_extract_seq:N #1
+  {
+    \seq_clear:N #1
+    \cs_set_eq:NN \@@_tmp:w  \@@_extract_seq_loop:Nw
+    \exp_after:wN \@@_extract_seq:NNn
+    \exp_after:wN #1
+    \g_@@_internal_tl \use_none:nnn
+  }
+\cs_new_protected:Npn \@@_extract_seq:NNn #1#2#3
+  { #3 #2 #1 \prg_do_nothing: }
+\cs_new_protected:Npn \@@_extract_seq_loop:Nw #1#2 \@@_tmp:w #3
+  {
+    \seq_put_right:No #1 {#2}
+    #3 \@@_extract_seq_loop:Nw #1 \prg_do_nothing:
   }
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \begin{macro}[EXP]{\@@_extract_seq_aux:n, \@@_extract_seq_aux:ww}
 %   The \texttt{:n} auxiliary builds one item of the sequence of
@@ -7090,35 +7109,6 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[EXP]
-%   {
-%     \@@_extract_map:N,
-%     \@@_extract_map_aux:NNn,
-%     \@@_extract_map_loop:w
-%   }
-%   This receives a |seq| internal function and maps it over all items
-%   in \cs{g_@@_internal_tl}.  This token list takes the form
-%   \cs{@@_tmp:w} |{}| \meta{item_1} \cs{@@_tmp:w} |{}| \meta{item_2}
-%   \ldots{} \cs{@@_tmp:w}, and the calling code has set \cs{@@_tmp:w}
-%   equal to \cs{@@_extract_map_loop:w}.  The loop is otherwise pretty
-%   standard, with \cs{prg_do_nothing:} to avoid losing braces.
-%    \begin{macrocode}
-\cs_new:Npn \@@_extract_map:N #1
-  {
-    \exp_after:wN \@@_extract_map_aux:NNn
-    \exp_after:wN #1
-    \g_@@_internal_tl \use_none:nnn
-  }
-\cs_new:Npn \@@_extract_map_aux:NNn #1#2#3
-  { #3 #2 #1 \prg_do_nothing: }
-\cs_new:Npn \@@_extract_map_loop:w #1#2 \@@_tmp:w #3
-  {
-    \exp_after:wN #1 \exp_after:wN {#2}
-    #3 \@@_extract_map_loop:w #1 \prg_do_nothing:
-  }
-%    \end{macrocode}
-% \end{macro}
-%
 % \begin{macro}{\@@_extract:, \@@_extract_aux:w}
 %   Our task here is to store the list of end-points of submatches, and
 %   store them in appropriate array entries, from





More information about the latex3-commits mailing list.