Re: C API - lua_next traversal of "array" table
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: C API - lua_next traversal of "array" table
- From: Daurnimator <quae@...>
- Date: 2016年8月19日 11:16:56 +1000
On 19 August 2016 at 10:48, ThePhD <jm3689@columbia.edu> wrote:
> My only problem is: how do I know how big the array part is? I could use
> `#t` or fight with its equivalent in the Lua 5.1/2/3 code, which is either
> lua_objlen or lua_rawlength (I can't remember which). Right now I have a
> fixed size at compile-time... I could just keep iterating integer keys from
> 1 to infinity until I hit a snag, but that seems less than useful (and
> doesn't allow me to pre-allocate the size to save performance).
>
> Any suggestions for getting the length, or is lua_objlen/rawlength (or
> whatever it is for each version of Lua) good enough?
Iterate until you get `nil`.