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

Marcel Fabian Krüger tex at 2krueger.de
Sun Nov 7 05:57:45 CET 2021


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

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

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

    Implement \intarray_gzero in Lua


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

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

diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index 79b0b0abf..5ac27da6a 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.