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

Bruno Le Floch blflatex at gmail.com
Tue Apr 27 09:44:12 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : gh590
Link       : https://github.com/latex3/latex3/commit/e772dbd7f8219b23a3e2aea432a69e4eed4e25ca

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

commit e772dbd7f8219b23a3e2aea432a69e4eed4e25ca
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


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

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

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 9c1612fde..27c0c8642 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -1250,9 +1250,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:
@@ -1264,9 +1262,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
@@ -1278,8 +1274,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}
@@ -1299,7 +1294,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}
 %
@@ -4929,7 +4926,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.