[latex3-commits] [git/LaTeX3-latex3-latex3] l3bitset-2: Faster int test (21d2e3bf2)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Jan 27 10:13:01 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : l3bitset-2
Link       : https://github.com/latex3/latex3/commit/21d2e3bf25d0d95c8d44722849d668d2819b8d7a

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

commit 21d2e3bf25d0d95c8d44722849d668d2819b8d7a
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Jan 27 09:13:01 2021 +0000

    Faster int test


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

21d2e3bf25d0d95c8d44722849d668d2819b8d7a
 l3experimental/l3bitset/l3bitset.dtx              | 34 ++++++++++++++++++++++-
 l3experimental/l3bitset/testfiles/m3bitset001.tlg |  1 +
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/l3experimental/l3bitset/l3bitset.dtx b/l3experimental/l3bitset/l3bitset.dtx
index c1df5e3a9..db167a331 100644
--- a/l3experimental/l3bitset/l3bitset.dtx
+++ b/l3experimental/l3bitset/l3bitset.dtx
@@ -370,6 +370,38 @@
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+%
+% \begin{variable}{\l_@@_internal_int}
+%    \begin{macrocode}
+\int_new:N \l_@@_internal_int
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}[TF]{\@@_test_int:n}
+% \begin{macro}{\@@_test_int_end:n}
+% \begin{macro}{\@@_test_int:wn}
+%   \url{https://chat.stackexchange.com/transcript/message/56878159#56878159}
+%    \begin{macrocode}
+\prg_new_protected_conditional:Npnn \@@_test_int:n #1 { TF }
+  {
+    \tex_afterassignment:D \@@_test_int:w
+    \l_@@_internal_int = 0 \tl_trim_spaces_apply:nN {#1} \tl_to_str:n
+    \@@_test_int_end:
+    \use_i:nnn \if_false:
+    \@@_test_int_end:
+    \if_int_compare:w \c_zero_int < \l_@@_internal_int
+      \prg_return_true:
+    \else:
+      \prg_return_false:
+    \fi:
+  }
+\cs_new_eq:NN \@@_test_int_end: \exp_stop_f:
+\cs_new_protected:Npn \@@_test_int:w #1 \@@_test_int_end: { }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% 
 % \begin{macro}
 %   {
 %     \bitset_set_true:Nn, \bitset_set_true:cn,
@@ -396,7 +428,7 @@
           }
       }
       {
-        \regex_match:nnTF { ^[\d]+$ } {#3}
+        \@@_test_int:nTF {#3}
           {
             #1 #2 {#3}
             \prop_gput:cnn { g_@@_ \cs_to_str:N #2 _name_prop } {#3} {#3}
diff --git a/l3experimental/l3bitset/testfiles/m3bitset001.tlg b/l3experimental/l3bitset/testfiles/m3bitset001.tlg
index 7b52fe34e..d5e9a362d 100644
--- a/l3experimental/l3bitset/testfiles/m3bitset001.tlg
+++ b/l3experimental/l3bitset/testfiles/m3bitset001.tlg
@@ -182,6 +182,7 @@ The bitset \l_my_testb_bitset has the representation:
 > arabic: 0.
 <recently read> }
 l. ... }
+LaTeX3 Warning: The name '0' is unknown for bitset \l_my_testb_bitset
 The bitset \l_my_testb_bitset has the representation:
 > binary: 1
 > arabic: 1.





More information about the latex3-commits mailing list.