7 ms·
That might be, but the C++ array append is bounds-checked which makes it half as fast as it could be too. It would be 16ns if there is no checking. So, you are
by fwsgonzo 6y ago
That might be, but the C++ array append is bounds-checked which makes it half as fast as it could be too. It would be 16ns if there is no checking. So, you are right but I am trying to do a balanced approach here. These benchmarks are made for me, and I want to write (more or less) normal code.
I don't want to write local table_insert = ...
I'd rather drop Lua for something else then. That said, it's cool that there are things you can do to speed things up if you really have to.
- anonymoushn 6y agoFair enough! I think t[#t+1] = x is not as offensive and will get you a few nanos less than the way with two table lookups, but if that's also not to your taste then that's fine.