[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: String parameters when calling C from Lua
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 19 May 2006 07:27:46 -0300
> Out of the two implementations I sketched out, would there be any
> significant performance difference between them? Basically I am
> interested in the relative efficiency of passing strings vs numbers from
> lua to C.
>From Lua to C, they have the same perfomance. From C to Lua, strings
have to hashed, even if they already exist in Lua. If you already have
a string as a Lua value and you want to pass it back to Lua, then you
can use lua_pushvalue and avoid the hash.
Back to your question, I think the main point is what you want to do
with strings in C. If you want to make decisions based on them and
have to strcmp them, then it'd be easier for C to do a switch on
integers. The Lua standard libraries convert strings to numbers for that;