From 3e9dbe143d3338f5f13a5e421ea593adff482da0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 18 Jan 2024 15:16:26 -0300 Subject: New function 'table.create' Creates a table preallocating memory. (It just exports to Lua the API function 'lua_createtable'.) --- manual/manual.of | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'manual') diff --git a/manual/manual.of b/manual/manual.of index 48f396d9..42269ff4 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -3234,11 +3234,11 @@ Values at other positions are not affected. } -@APIEntry{void lua_createtable (lua_State *L, int narr, int nrec);| +@APIEntry{void lua_createtable (lua_State *L, int nseq, int nrec);| @apii{0,1,m} Creates a new empty table and pushes it onto the stack. -Parameter @id{narr} is a hint for how many elements the table +Parameter @id{nseq} is a hint for how many elements the table will have as a sequence; parameter @id{nrec} is a hint for how many other elements the table will have. @@ -7969,6 +7969,19 @@ If @id{i} is greater than @id{j}, returns the empty string. } +@LibEntry{table.create (nseq [, nrec])| + +Creates a new empty table, preallocating memory. +This preallocation may help performance and save memory +when you know in advance how many elements the table will have. + +Parameter @id{nseq} is a hint for how many elements the table +will have as a sequence. +Optional parameter @id{nrec} is a hint for how many other elements +the table will have; its default is zero. + +} + @LibEntry{table.insert (list, [pos,] value)| Inserts element @id{value} at position @id{pos} in @id{list}, -- cgit v1.2.3-55-g6feb