2014-12-10 21:56 GMT+01:00 Joe Ellsworth <joexdobs@xxxxxxxxx>: > Good catch. Corrected code is http://pastebin.com/jniGqHyp The FFI > code is still a little faster but not by much. The generated code in case of the native lua array is almost the same as the ffi one, the only additional instructions are just to check if the index is in the array part of the table (I think), so it might not be worth doing this optimization in this specific usage. However, if the items are not numbers (doubles), but compound types/structs, then the lua version would store pointers in the array instead of the data itself, while with ffi you can make an array of the structs, which would probably be faster. Actually, the example on the ffi page I linked before demonstrates exactly this kind of usage.