lua-users home
lua-l archive

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


On Mon, 12 Oct 2009 12:30:22 -0700
Chris Gagnon <cgagnon@zindagigames.com> wrote:

> I'm come to a situation, where to maintain readability for script
> writers but ensure fast code i want to parse lua code before it goes
> to the compiler.
> The issue i foresee is that I'll essentially want to create user data
> in the Lua script.
> 
> So an example in Lua:
> PostEvent("ButtonClick")
> very readable, however strings...yuck
> 
> I want to create a hash of that string for speed:
> PostEvent( 0xABC45678 )

Have you actually benchmarked this?  The string will be folded into the
constants table at compile time, and should take a similar amount of
time to load from it as a numerical constant.  Additionally, string
comparison for equality boils down to a single pointer compare, so is
very quick; not to mention more readable.

B.