[latex3-commits] [git/LaTeX3-latex3-latex3] master: Avoid repeated use of \utex_char:D (9ae4dad)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Apr 25 23:37:26 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/9ae4dadecad06fecd94f45c1c8b881d5757f95f8

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

commit 9ae4dadecad06fecd94f45c1c8b881d5757f95f8
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Apr 25 22:37:26 2018 +0100

    Avoid repeated use of \utex_char:D
    
    There is no need to use the primitive directly here as we can do the job
    using \char_generate:nn.
    
    We may want to think about a 'generic Unicode engine' switch, something
    like \sys_if_engine_unicode_p: or \sys_if_enigine_utex_p: (as we already
    use utex for some primitives).


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

9ae4dadecad06fecd94f45c1c8b881d5757f95f8
 l3kernel/l3candidates.dtx |   55 +++++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 19 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 5e9ed73..88f98ad 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -3223,7 +3223,9 @@
 %   Unicode character, which is then used in a lookup. (As will become
 %   obvious below, there is no intention here of covering all of Unicode.)
 %    \begin{macrocode}
-\cs_if_exist:NTF \utex_char:D
+\bool_lazy_or:nnTF
+  { \sys_if_engine_luatex_p: }
+  { \sys_if_engine_xetex_p: }
   {
     \cs_new:Npn \@@_change_case_char:nN #1#2
       {
@@ -3254,7 +3256,9 @@
 %   To allow for the special case of mixed case, we insert here a
 %   action-dependent auxiliary.
 %    \begin{macrocode}
-\cs_if_exist:NF \utex_char:D
+\bool_lazy_or:nnF
+  { \sys_if_engine_luatex_p: }
+  { \sys_if_engine_xetex_p: }
   {
     \cs_new:Npn \@@_change_case_char_UTFviii:nNNN #1#2#3#4
       { \@@_change_case_char_UTFviii:nnN {#1} {#2#4} #3 }
@@ -3534,7 +3538,9 @@
 %   either a dotless-I or a dotted-I. In the latter case the mapping is
 %   easy, but in the former there is a second stage search.
 %    \begin{macrocode}
-\cs_if_exist:NTF \utex_char:D
+\bool_lazy_or:nnTF
+  { \sys_if_engine_luatex_p: }
+  { \sys_if_engine_xetex_p: }
   {
     \cs_new:Npn \@@_change_case_lower_tr:Nnw #1#2
       {
@@ -3802,21 +3808,27 @@
 %   This set are only available in Unicode engines, with no-op definitions
 %   for $8$-bit use.
 %    \begin{macrocode}
-\cs_if_exist:NTF \utex_char:D
+\bool_lazy_or:nnTF
+  { \sys_if_engine_luatex_p: }
+  { \sys_if_engine_xetex_p: }
   {
-    \tl_const:Nx \c_@@_std_sigma_tl    { \utex_char:D "03C3 ~ }
-    \tl_const:Nx \c_@@_final_sigma_tl  { \utex_char:D "03C2 ~ }
-    \tl_const:Nx \c_@@_accents_lt_tl
-      {
-        \utex_char:D "00CC ~
-          { \utex_char:D "0069 ~ \utex_char:D "0307 ~ \utex_char:D "0300 ~ }
-        \utex_char:D "00CD ~
-          { \utex_char:D "0069 ~ \utex_char:D "0307 ~ \utex_char:D "0301 ~ }
-        \utex_char:D "0128 ~
-          { \utex_char:D "0069 ~ \utex_char:D "0307 ~ \utex_char:D "0303 ~ }
-      }
-    \tl_const:Nx \c_@@_dot_above_tl    { \utex_char:D "0307 ~ }
-    \tl_const:Nx \c_@@_upper_Eszett_tl { \utex_char:D "1E9E ~ }
+    \group_begin:
+      \cs_set:Npn \@@_tmp:n #1
+        { \char_generate:nn {#1} { \char_value_catcode:n {#1} } }
+      \tl_const:Nx \c_@@_std_sigma_tl    { \@@_tmp:n { "03C3 } }
+      \tl_const:Nx \c_@@_final_sigma_tl  { \@@_tmp:n { "03C2 } }
+      \tl_const:Nx \c_@@_accents_lt_tl
+        {
+          \@@_tmp:n { "00CC }
+            { \@@_tmp:n { "0069 } \@@_tmp:n { "0307 } \@@_tmp:n { "0300 } }
+          \@@_tmp:n { "00CD }
+            { \@@_tmp:n { "0069 } \@@_tmp:n { "0307 } \@@_tmp:n { "0301 } }
+          \@@_tmp:n { "0128 }
+            { \@@_tmp:n { "0069 } \@@_tmp:n { "0307 } \@@_tmp:n { "0303 } }
+        }
+      \tl_const:Nx \c_@@_dot_above_tl    { \@@_tmp:n { "0307 } }
+      \tl_const:Nx \c_@@_upper_Eszett_tl { \@@_tmp:n { "1E9E } }
+    \group_end:
   }
   {
       \tl_const:Nn \c_@@_std_sigma_tl    { }
@@ -3838,10 +3850,15 @@
 %  a variant is provided in both cases.
 %    \begin{macrocode}
 \group_begin:
-  \cs_if_exist:NTF \utex_char:D
+  \bool_lazy_or:nnTF
+    { \sys_if_engine_luatex_p: }
+    { \sys_if_engine_xetex_p: }
     {
       \cs_set_protected:Npn \@@_tmp:w #1#2
-        { \tl_const:Nx #1 { \utex_char:D "#2 \exp_stop_f: } }
+        {
+          \tl_const:Nx #1
+            { \char_generate:nn {"#2} { \char_value_catcode:n {"#2} } }
+        }
     }
     {
       \cs_set_protected:Npn \@@_tmp:w #1#2





More information about the latex3-commits mailing list