lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Javier Guerra kirjoitti 17.12.2007 kello 23:03:

On 12/17/07, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
using pushstring() feels unoptimal.
That's the problem: it *feels* unoptimal but in reality, as Rici  
reported,
it does not make any actual difference, not enough to warrant a  
complicated,
error-prone, ugly API...

Yet another lesson at the wrong perceptions that we programmers have about
performance...
i really want to agree; and of course it warrants a benchmark or two.

but still, using string constants in Lua is (almost?) as light as
using integers, and i'd like to have this from C; ideally using enums
that get translated to already-interned lua strings.

unfortunately, i don't believe there's a neat solution.

--
Javier
You can push all the strings in startup on the registry, with light  
userdata pointers (of the C side string constant) serving as keys.  
This will turn string pushing into a table lookup instead; maybe no  
better at all?
-asko