[latex3-commits] [git/LaTeX3-latex3-latex3] master: Speed up bool_lazy_or and bool_lazy_and (6fb3c19)
Bruno Le Floch
bruno at le-floch.fr
Wed May 9 20:10:38 CEST 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/6fb3c1958834ba67238efc85519ada900d7e698c
>---------------------------------------------------------------
commit 6fb3c1958834ba67238efc85519ada900d7e698c
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Wed May 9 14:10:38 2018 -0400
Speed up bool_lazy_or and bool_lazy_and
>---------------------------------------------------------------
6fb3c1958834ba67238efc85519ada900d7e698c
l3kernel/l3prg.dtx | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/l3kernel/l3prg.dtx b/l3kernel/l3prg.dtx
index 0c37cd3..32d8cb1 100644
--- a/l3kernel/l3prg.dtx
+++ b/l3kernel/l3prg.dtx
@@ -1182,13 +1182,21 @@
% is \texttt{false}. If the end is reached without finding any
% \texttt{false} expression, then the result is \texttt{true}.
% \begin{macrocode}
-\prg_new_conditional:Npnn \bool_lazy_all:n #1 { p , T , F , TF }
+\cs_new:Npn \bool_lazy_all_p:n #1
{ \@@_lazy_all:n #1 \q_recursion_tail \q_recursion_stop }
+\prg_new_conditional:Npnn \bool_lazy_all:n #1 { T , F , TF }
+ {
+ \if_predicate:w \bool_lazy_all_p:n {#1}
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
\cs_new:Npn \@@_lazy_all:n #1
{
- \quark_if_recursion_tail_stop_do:nn {#1} { \prg_return_true: }
+ \quark_if_recursion_tail_stop_do:nn {#1} { \c_true_bool }
\bool_if:nF {#1}
- { \use_i_delimit_by_q_recursion_stop:nw { \prg_return_false: } }
+ { \use_i_delimit_by_q_recursion_stop:nw { \c_false_bool } }
\@@_lazy_all:n
}
% \end{macrocode}
@@ -1221,13 +1229,21 @@
% is \texttt{true}. If the end is reached without finding any
% \texttt{true} expression, then the result is \texttt{false}.
% \begin{macrocode}
-\prg_new_conditional:Npnn \bool_lazy_any:n #1 { p , T , F , TF }
+\cs_new:Npn \bool_lazy_any_p:n #1
{ \@@_lazy_any:n #1 \q_recursion_tail \q_recursion_stop }
+\prg_new_conditional:Npnn \bool_lazy_any:n #1 { T , F , TF }
+ {
+ \if_predicate:w \bool_lazy_any_p:n {#1}
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ }
\cs_new:Npn \@@_lazy_any:n #1
{
- \quark_if_recursion_tail_stop_do:nn {#1} { \prg_return_false: }
+ \quark_if_recursion_tail_stop_do:nn {#1} { \c_false_bool }
\bool_if:nT {#1}
- { \use_i_delimit_by_q_recursion_stop:nw { \prg_return_true: } }
+ { \use_i_delimit_by_q_recursion_stop:nw { \c_true_bool } }
\@@_lazy_any:n
}
% \end{macrocode}
More information about the latex3-commits
mailing list