2014-03-07 13:42 GMT+04:00 Mike Pall <mike-1403@xxxxxxxxxx>: > Dynamically generate Lua source code that scans the data using > the FFI. Something like this, where d is an FFI struct > (untested code, typed into the mail): > Thanks for your feedback, Mike! I got your general idea, though it seems that I want something lower-level, something that chews through raw bytes of an encoded object, doing as less as possible for chunks of input that are irrelevant, e.g. skipping a length-prefixed portion of bytes as soon as it's length is decoded without touching them. The object comes to me as a void * and a size_t denoting it's total length. So according to your guideline, I need to generate a Lua function which will iterate through each byte, skipping if necessary and doing some bitop magic, and for each matched field, decode it (if required) and compare according to the match_list[field_index]. Does it still sound JIT-friendly? -- Regards, Konstantin