On Tue, Jan 17, 2012 at 4:04 AM, Peter Cawley
<lua@corsix.org> wrote:
In one of my current projects, I have a similar need to frequently
switch over a Lua string. I opted for a solution of hash-based
dispatch combined with code generation, which I don't think I've seen
proposed on lua-l recently. I've written up a description of the
approach as a blog post:
The assumption in your design is that the hash function will not change. It's likely that future Lua versions will have some kind of randomized hash function to prevent some types of denial-of-service attacks that were discussed here recently, and then this scheme no longer works. The really good part of the design is that you use a code generation tool, so you can easily change how things work without rewriting half you code base.
Gé