[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: packing a table (array vs hash)
- From: Alexander Gladysh <agladysh@...>
- Date: Sun, 2 Jan 2011 17:33:17 +0300
On Fri, Dec 31, 2010 at 18:07, Gaspard Bucher <gaspard@teti.ch> wrote:
> I understand your point. I am not saying a table in Lua is this or that and
> I agree that it I have to use an arbitrary rule. I am currently using "no
> value in array" means hash:
> if (lua_objlen(L, index) > 0)
> pack_as_array(L, index);
> else
> pack_as_hash(L, index);
This would not work. This table layout is a common idiom:
{
"alpha";
"beta";
gamma = "delta";
}
> I am also wondering if there is a faster method to get the hash size (needed
> to prepare the map):
> for(lua_pushnil(L); lua_next(L, index) != 0; lua_pop(L, 1)) ++sz;
That bad?
I'm not familiar with msgpack or zeroMQ, but this may (or may not) be helpful:
https://github.com/agladysh/luabins/blob/master/src/save.c#L29
Alexander.