[latex3-commits] [git/LaTeX3-latex3-latex3] main: Optimize computation of case-changed char in caseless regex (b780b51cc)

Bruno Le Floch blflatex at gmail.com
Tue Apr 27 15:56:19 CEST 2021


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

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

commit b780b51cc7bcf238bc8392b803da6f08dc60976a
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Tue Apr 27 09:44:12 2021 +0200

    Optimize computation of case-changed char in caseless regex


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

b780b51cc7bcf238bc8392b803da6f08dc60976a
 l3kernel/l3regex.dtx | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 6b7c371c8..da63a0c45 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -1257,9 +1257,7 @@
     \if_int_compare:w #1 = \l_@@_curr_char_int
       \exp_after:wN \@@_break_true:w
     \fi:
-    \if_int_compare:w \l_@@_case_changed_char_int = \c_max_int
-      \@@_compute_case_changed_char:
-    \fi:
+    \@@_maybe_compute_ccc:
     \if_int_compare:w #1 = \l_@@_case_changed_char_int
       \exp_after:wN \@@_break_true:w
     \fi:
@@ -1271,9 +1269,7 @@
         \exp_after:wN \exp_after:wN \exp_after:wN \@@_break_true:w
       \fi:
     \fi:
-    \if_int_compare:w \l_@@_case_changed_char_int = \c_max_int
-      \@@_compute_case_changed_char:
-    \fi:
+    \@@_maybe_compute_ccc:
     \reverse_if:N \if_int_compare:w #1 > \l_@@_case_changed_char_int
       \reverse_if:N \if_int_compare:w #2 < \l_@@_case_changed_char_int
         \exp_after:wN \exp_after:wN \exp_after:wN \@@_break_true:w
@@ -1285,8 +1281,7 @@
 %
 % \begin{macro}{\@@_compute_case_changed_char:}
 %   This function is called when \cs{l_@@_case_changed_char_int} has
-%   not yet been computed (or rather, when it is set to the marker value
-%   \cs{c_max_int}). If the current character code is in the range
+%   not yet been computed. If the current character code is in the range
 %   $[65,90]$ (upper-case), then add $32$, making it lowercase. If it is
 %   in the lower-case letter range $[97,122]$, subtract $32$.
 %    \begin{macrocode}
@@ -1306,7 +1301,9 @@
           { \c_@@_ascii_lower_int }
       \fi:
     \fi:
+    \cs_set_eq:NN \@@_maybe_compute_ccc: \prg_do_nothing:
   }
+\cs_new_eq:NN \@@_maybe_compute_ccc: \@@_compute_case_changed_char:
 %    \end{macrocode}
 % \end{macro}
 %
@@ -4936,7 +4933,7 @@
     \int_add:Nn \l_@@_step_int { 2 }
     \int_incr:N \l_@@_curr_pos_int
     \int_set_eq:NN \l_@@_last_char_int \l_@@_curr_char_int
-    \int_set_eq:NN \l_@@_case_changed_char_int \c_max_int
+    \cs_set_eq:NN \@@_maybe_compute_ccc: \@@_compute_case_changed_char:
     \tl_set:Nn \l_@@_curr_token_tl {#1}
     \int_set:Nn \l_@@_curr_char_int {#2}
     \int_set:Nn \l_@@_curr_catcode_int { "#3 }





More information about the latex3-commits mailing list.