[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Is there some way to set table capacity in pure lua code?
- From: 云风 Cloud Wu <cloudwu@...>
- Date: Thu, 3 Aug 2023 19:50:54 +0800
zhao xin <esrrhs@163.com> 于2023年8月3日周四 12:59写道:
> I know the lua_createtable can do this thing, but it will call C function.
> so is the possible add some support in lua?
>
> local t = {(100, 0)} -- give t 100 array capacity
You may need:
local t = { table.unpack({}, 1, 100) }
But I think 100 is a very small number, you don't need reserve the new
array table for this small size.
--
http://blog.codingnow.com