[latex3-commits] [latex3/latex3] main: Parse each opacity fp expr only once (fe09580fa)

github at latex-project.org github at latex-project.org
Sat Mar 2 08:27:37 CET 2024


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

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

commit fe09580fa5b360d787cd00907a5c159d3824196b
Author: Yukai Chou <muzimuzhi at gmail.com>
Date:   Fri Mar 1 05:50:46 2024 +0800

    Parse each opacity fp expr only once


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

fe09580fa5b360d787cd00907a5c159d3824196b
 l3experimental/CHANGELOG.md            |  3 +++
 l3experimental/l3opacity/l3opacity.dtx | 21 ++++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/l3experimental/CHANGELOG.md b/l3experimental/CHANGELOG.md
index cd7e71778..ac248276c 100644
--- a/l3experimental/CHANGELOG.md
+++ b/l3experimental/CHANGELOG.md
@@ -10,6 +10,9 @@ this project uses date-based 'snapshot' version identifiers.
 ### Added
 - `\draw_path_replace_bb:`
 
+### Changed
+- `l3opacity` is sped up a bit
+
 ### Fixed
 - Interaction between drawing rotation and shift (issue \#1483)
 - Shifting not applied to `\draw_path_rectangle:n` (issue \#1486)
diff --git a/l3experimental/l3opacity/l3opacity.dtx b/l3experimental/l3opacity/l3opacity.dtx
index 05a946339..78d06a688 100644
--- a/l3experimental/l3opacity/l3opacity.dtx
+++ b/l3experimental/l3opacity/l3opacity.dtx
@@ -106,9 +106,17 @@
   {L3 Experimental opacity support}
 %    \end{macrocode}
 %
+% \begin{variable}
+%   Temporary storage.
+%    \begin{macrocode}
+\fp_new:N \l_@@_tmp_fp
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{macro}{\opacity_select:n, \opacity_fill:n, \opacity_stroke:n}
-% \begin{macro}{\@@_select:nN, \@@_select_aux:nN}
-%   Thin wrapper with error checking.
+% \begin{macro}{\@@_select:nN}
+%   Thin wrapper with error checking. Opacity is passed to backend
+% functions as a bounded, evaluated decimal number.
 %    \begin{macrocode}
 \cs_new_protected:Npn \opacity_select:n #1
   { \@@_select:nN {#1} \@@_backend_select:n }
@@ -117,14 +125,13 @@
 \cs_new_protected:Npn \opacity_stroke:n #1
   { \@@_select:nN {#1} \@@_backend_stroke:n }
 \cs_new_protected:Npn \@@_select:nN #1#2
-  { \exp_args:Ne \@@_select_aux:nN { \fp_eval:n {#1} } #2 }
-\cs_new_protected:Npn \@@_select_aux:nN #1#2
   {
+    \fp_set:Nn \l_@@_tmp_fp { #1 }
     \bool_lazy_or:nnTF
-      { \fp_compare_p:nNn {#1} < { 0 } }
-      { \fp_compare_p:nNn {#1} > { 1 } }
+      { \fp_compare_p:nNn \l_@@_tmp_fp < \c_zero_fp }
+      { \fp_compare_p:nNn \l_@@_tmp_fp > \c_one_fp }
       { \msg_error:nnn { opacity } { out-of-range } {#1} }
-      { #2 {#1} }
+      { \exp_args:Ne #2 { \fp_use:N \l_@@_tmp_fp } }
   }
 \msg_new:nnnn { opacity } { out-of-range }
   { Opacity~value~out~of~range. }





More information about the latex3-commits mailing list.