[latex3-commits] [git/LaTeX3-latex3-latex3] luaintarray: Implement \intarray_gzero in Lua (0057d3d94)

Marcel Fabian Krüger tex at 2krueger.de
Sun Nov 7 06:30:17 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : luaintarray
Link       : https://github.com/latex3/latex3/commit/0057d3d942cc096c27adc99ff8a995b42b4adadb

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

commit 0057d3d942cc096c27adc99ff8a995b42b4adadb
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sun Nov 7 04:52:47 2021 +0100

    Implement \intarray_gzero in Lua


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

0057d3d942cc096c27adc99ff8a995b42b4adadb
 l3kernel/l3intarray.dtx | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index d02a6cf19..d7ea1e7cb 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -393,24 +393,23 @@ end, 'protected', 'global')
       }
   }
 \cs_generate_variant:Nn \intarray_gset:Nnn { c }
+%</tex>
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\intarray_gzero:N, \intarray_gzero:c}
 %   Set the appropriate \tn{fontdimen} to zero.  No bound checking
-%   needed.  The \cs{prg_replicate:nn} possibly uses quite a lot of
-%   memory, but this is somewhat comparable to the size of the array,
-%   and it is much faster than an \cs{int_step_inline:nn} loop.
+%   needed.
 %    \begin{macrocode}
-\cs_new_protected:Npn \intarray_gzero:N #1
-  {
-    \int_zero:N \l_@@_loop_int
-    \prg_replicate:nn { \intarray_count:N #1 }
-      {
-        \int_incr:N \l_@@_loop_int
-        \@@_gset:wNwF \l_@@_loop_int #1 \c_zero_dim {}
-      }
-  }
+%<*lua>
+luacmd('intarray_gzero:N', function()
+  local t = @@_table()
+  for i=1, #t do
+    t[i] = 0
+  end
+end, 'global', 'protected')
+%</lua>
+%<*tex>
 \cs_generate_variant:Nn \intarray_gzero:N { c }
 %</tex>
 %    \end{macrocode}





More information about the latex3-commits mailing list.