[latex3-commits] [git/LaTeX3-latex3-latex3] master: Rationalise \int_eval:n vs. \@@_int_eval:w (a94ab77)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 27 10:31:06 CEST 2018


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

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

commit a94ab776953470153ba85ebf4b39415f7901fe45
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Mar 27 09:31:01 2018 +0100

    Rationalise \int_eval:n vs. \@@_int_eval:w
    
    This is a tidy up of the 'already done' work.
    Where we can avoid the primitive entirely, we do.
    Otherwise we keep it for all uses in a module.


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

a94ab776953470153ba85ebf4b39415f7901fe45
 l3kernel/l3regex.dtx                    |    4 ++--
 l3kernel/l3sort.dtx                     |    5 +----
 l3kernel/l3str.dtx                      |    5 +++--
 l3kernel/l3tl-analysis.dtx              |    9 +++------
 l3kernel/l3token.dtx                    |   14 ++++++--------
 l3kernel/testfiles/m3expl001.luatex.tlg |    3 ---
 l3kernel/testfiles/m3expl001.ptex.tlg   |    3 ---
 l3kernel/testfiles/m3expl001.tlg        |    3 ---
 l3kernel/testfiles/m3expl001.uptex.tlg  |    3 ---
 l3kernel/testfiles/m3expl001.xetex.tlg  |    3 ---
 l3kernel/testfiles/m3expl003.luatex.tlg |    3 ---
 l3kernel/testfiles/m3expl003.ptex.tlg   |    3 ---
 l3kernel/testfiles/m3expl003.tlg        |    3 ---
 l3kernel/testfiles/m3expl003.uptex.tlg  |    3 ---
 l3kernel/testfiles/m3expl003.xetex.tlg  |    3 ---
 15 files changed, 15 insertions(+), 52 deletions(-)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index 32aa9b9..bd0c483 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -919,8 +919,8 @@
 %
 % \begin{macro}
 %   {\@@_int_eval:w}
-%   Access to primitives: the code here uses the expansion behaviors for
-%   efficiency.
+%   Access the primitive: performance is key here, so we do not use
+%   the slower route \emph{via} \cs{int_eval:n}.
 %    \begin{macrocode}
 \cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D
 %     \end{macrocode}
diff --git a/l3kernel/l3sort.dtx b/l3kernel/l3sort.dtx
index 2302364..9ae5660 100644
--- a/l3kernel/l3sort.dtx
+++ b/l3kernel/l3sort.dtx
@@ -435,7 +435,6 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_toks:NN, \@@_toks:NNw}
-% \begin{macro}{\@@_int_eval:w}
 %   Unpack the various \tn{toks} registers, from \cs{l_@@_min_int} to
 %   $\cs{l_@@_top_int}-1$. The functions |#1| and |#2| allow us to treat
 %   the three data structures in a unified way:
@@ -458,13 +457,11 @@
     \if_int_compare:w #3 < \l_@@_top_int
       #1 #2 { \tex_the:D \tex_toks:D #3 }
       \exp_after:wN \@@_toks:NNw \exp_after:wN #1 \exp_after:wN #2
-      \int_value:w \@@_int_eval:w #3 + 1 \exp_after:wN ;
+      \int_value:w \int_eval:n { #3 + 1 } \exp_after:wN ;
     \fi:
   }
-\cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
 %
 % \subsection{Merge sort}
 %
diff --git a/l3kernel/l3str.dtx b/l3kernel/l3str.dtx
index 96b2a72..8c3289a 100644
--- a/l3kernel/l3str.dtx
+++ b/l3kernel/l3str.dtx
@@ -878,8 +878,9 @@
 %    \end{macrocode}
 %
 % \begin{macro}{\@@_int_eval:w}
-%   Access to primitives: the code here uses the expansion behaviors for
-%   efficiency.
+%   Access to primitive: there are a few uses where we cannot grab the
+%   expression as an argument, so need the \texttt{w} signature. Other cases
+%   are retained (no using \cs{int_eval:n}) as there is a performance gain.
 %    \begin{macrocode}
 \cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D
 %    \end{macrocode}
diff --git a/l3kernel/l3tl-analysis.dtx b/l3kernel/l3tl-analysis.dtx
index 5d15217..39a8092 100644
--- a/l3kernel/l3tl-analysis.dtx
+++ b/l3kernel/l3tl-analysis.dtx
@@ -168,13 +168,10 @@
 %
 % \subsection{Variables and helper functions}
 %
-% \begin{macro}
-%   {\@@_int_eval:w, \@@_int_eval_end:}
-%   Access to primitives: the code here uses the expansion behaviors for
-%   efficiency.
+% \begin{macro}{\@@_int_eval:w}
+%   Access to primitive: we need the efficiency here.
 %    \begin{macrocode}
 \cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D
-\cs_new_eq:NN \@@_int_eval_end: \scan_stop:
 %    \end{macrocode}
 % \end{macro}
 %
@@ -835,7 +832,7 @@
     \if_int_compare:w #1 = 0 \exp_stop_f:
       #3
     \else:
-      \tex_skip:D \@@_int_eval:w #4 + #1 \@@_int_eval_end:
+      \tex_skip:D \@@_int_eval:w #4 + #1 \scan_stop:
     \fi:
     - #2
     \exp_after:wN ;
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index dfa7a61..77bd61a 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -1354,12 +1354,10 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}
-%   {\@@_int_eval:w, \@@_int_to_roman:w}
-%   Access to primitives: the code here uses the expansion behaviors for
-%   efficiency.
+% \begin{macro}{\@@_int_to_roman:w}
+%   For efficiency in 8-bit engines, we use the faster primitive approach
+%   to making roman numerals.
 %    \begin{macrocode}
-\cs_new_eq:NN \@@_int_eval:w \etex_numexpr:D
 \cs_new_eq:NN \@@_int_to_roman:w \tex_romannumeral:D
 %    \end{macrocode}
 % \end{macro}
@@ -1381,14 +1379,14 @@
 \cs_new:Npn \char_generate:nn #1#2
   {
     \exp:w \exp_after:wN \@@_generate_aux:w
-      \int_value:w \@@_int_eval:w #1 \exp_after:wN ;
-      \int_value:w \@@_int_eval:w #2 ;
+      \int_value:w \int_eval:n {#1} \exp_after:wN ;
+      \int_value:w \int_eval:n {#2} ;
   }
 \cs_new:Npn \__kernel_char_generate:nn #1#2
   {
     \exp:w \exp_after:wN
       \@@_generate_aux:nnw \exp_after:wN
-        { \int_value:w \@@_int_eval:w #1 } {#2} \exp_end:
+        { \int_value:w \int_eval:n {#1} } {#2} \exp_end:
   }
 %    \end{macrocode}
 %   Before doing any actual conversion, first some special case filtering.
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index d9ca096..3d4a030 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -2403,7 +2403,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4651,7 +4650,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4708,7 +4706,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index b4976eb..dfbee6e 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -2084,7 +2084,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4588,7 +4587,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4645,7 +4643,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 10e5e38..5c5e490 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -2084,7 +2084,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4588,7 +4587,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4645,7 +4643,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 2a7abaa..f511991 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -2084,7 +2084,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4588,7 +4587,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4645,7 +4643,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index c56a2ae..9670d1f 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -2401,7 +2401,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4628,7 +4627,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4685,7 +4683,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index d9ca096..3d4a030 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -2403,7 +2403,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4651,7 +4650,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4708,7 +4706,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index b4976eb..dfbee6e 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -2084,7 +2084,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4588,7 +4587,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4645,7 +4643,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 10e5e38..5c5e490 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -2084,7 +2084,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4588,7 +4587,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4645,7 +4643,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 2a7abaa..f511991 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -2084,7 +2084,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4588,7 +4587,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4645,7 +4643,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index c56a2ae..9670d1f 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -2401,7 +2401,6 @@ Defining \char_set_active_eq:Nc on line ...
 Defining \char_gset_active_eq:Nc on line ...
 Defining \char_set_active_eq:nc on line ...
 Defining \char_gset_active_eq:nc on line ...
-Defining \__char_int_eval:w on line ...
 Defining \__char_int_to_roman:w on line ...
 Defining \char_generate:nn on line ...
 Defining \__kernel_char_generate:nn on line ...
@@ -4628,7 +4627,6 @@ Defining \clist_gsort:cn on line ...
 Defining \__sort_clist:NNn on line ...
 Defining \__sort_toks:NN on line ...
 Defining \__sort_toks:NNw on line ...
-Defining \__sort_int_eval:w on line ...
 Defining \__sort_level: on line ...
 Defining \__sort_merge_blocks: on line ...
 Defining \__sort_copy_block: on line ...
@@ -4685,7 +4683,6 @@ Defining \__tl_build_one:n on line ...
 Defining \__tl_build_one:o on line ...
 Defining \__tl_build_one:x on line ...
 Defining \__tl_analysis_int_eval:w on line ...
-Defining \__tl_analysis_int_eval_end: on line ...
 Defining \s__tl on line ...
 Defining \l__tl_analysis_internal_tl on line ...
 Defining \l__tl_analysis_token on line ...





More information about the latex3-commits mailing list