[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua Pre-compiler / Lua side userdata
- From: Rob Kendrick <lua-l@...>
- Date: Mon, 12 Oct 2009 20:54:09 +0100
On Mon, 12 Oct 2009 12:30:22 -0700
Chris Gagnon <email@example.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:
> 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.