summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3kernel/l3int.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3int.dtx')
-rw-r--r--macros/latex/contrib/l3kernel/l3int.dtx38
1 files changed, 20 insertions, 18 deletions
diff --git a/macros/latex/contrib/l3kernel/l3int.dtx b/macros/latex/contrib/l3kernel/l3int.dtx
index 5994a193c6..505afcd9ee 100644
--- a/macros/latex/contrib/l3kernel/l3int.dtx
+++ b/macros/latex/contrib/l3kernel/l3int.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2021-05-11}
+% \date{Released 2021-05-25}
%
% \maketitle
%
@@ -1088,13 +1088,14 @@
%
% \begin{macro}{\int_eval:n}
% \begin{macro}{\int_eval:w}
-% Wrapper for \cs{@@_eval:w}: can be used in an integer expression
-% or directly in the input stream.
-% When debugging, use parentheses to catch early termination.
+% Wrapper for \cs{@@_eval:w}: can be used in an integer expression or
+% directly in the input stream. It is very slightly faster to use
+% \tn{the} rather than \tn{number} to turn the expression to a number.
+% When debugging, we introduce parentheses to catch early termination (see \pkg{l3debug}).
% \begin{macrocode}
\cs_new:Npn \int_eval:n #1
- { \int_value:w \@@_eval:w #1 \@@_eval_end: }
-\cs_new:Npn \int_eval:w { \int_value:w \@@_eval:w }
+ { \tex_the:D \@@_eval:w #1 \@@_eval_end: }
+\cs_new:Npn \int_eval:w { \tex_the:D \@@_eval:w }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1399,15 +1400,17 @@
% \begin{macro}{\int_gsub:Nn, \int_gsub:cn}
% \UnitTested
% Adding and subtracting to and from a counter.
+% Including here the optional |by| would slow down these operations
+% by a few percent.
% \begin{macrocode}
\cs_new_protected:Npn \int_add:Nn #1#2
- { \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: }
+ { \tex_advance:D #1 \@@_eval:w #2 \@@_eval_end: }
\cs_new_protected:Npn \int_sub:Nn #1#2
- { \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: }
+ { \tex_advance:D #1 - \@@_eval:w #2 \@@_eval_end: }
\cs_new_protected:Npn \int_gadd:Nn #1#2
- { \tex_global:D \tex_advance:D #1 by \@@_eval:w #2 \@@_eval_end: }
+ { \tex_global:D \tex_advance:D #1 \@@_eval:w #2 \@@_eval_end: }
\cs_new_protected:Npn \int_gsub:Nn #1#2
- { \tex_global:D \tex_advance:D #1 by - \@@_eval:w #2 \@@_eval_end: }
+ { \tex_global:D \tex_advance:D #1 - \@@_eval:w #2 \@@_eval_end: }
\cs_generate_variant:Nn \int_add:Nn { c }
\cs_generate_variant:Nn \int_gadd:Nn { c }
\cs_generate_variant:Nn \int_sub:Nn { c }
@@ -1452,12 +1455,14 @@
% \begin{macro}{\int_gset:Nn, \int_gset:cn}
% \UnitTested
% As integers are register-based \TeX{} issues an error
-% if they are not defined.
+% if they are not defined. While the |=| sign is optional, this
+% version with |=| is slightly quicker than without, while adding the
+% optional space after |=| slows things down minutely.
% \begin{macrocode}
\cs_new_protected:Npn \int_set:Nn #1#2
- { #1 ~ \@@_eval:w #2 \@@_eval_end: }
+ { #1 = \@@_eval:w #2 \@@_eval_end: }
\cs_new_protected:Npn \int_gset:Nn #1#2
- { \tex_global:D #1 ~ \@@_eval:w #2 \@@_eval_end: }
+ { \tex_global:D #1 = \@@_eval:w #2 \@@_eval_end: }
\cs_generate_variant:Nn \int_set:Nn { c }
\cs_generate_variant:Nn \int_gset:Nn { c }
% \end{macrocode}
@@ -1468,13 +1473,10 @@
%
% \begin{macro}{\int_use:N, \int_use:c}
% \UnitTested
-% Here is how counters are accessed:
+% Here is how counters are accessed.
+% We hand-code the |c| variant for some speed gain.
% \begin{macrocode}
\cs_new_eq:NN \int_use:N \tex_the:D
-% \end{macrocode}
-% We hand-code this for some speed gain:
-% \begin{macrocode}
-%\cs_generate_variant:Nn \int_use:N { c }
\cs_new:Npn \int_use:c #1 { \tex_the:D \cs:w #1 \cs_end: }
% \end{macrocode}
% \end{macro}