GitHub - pocomane/lua-length-patch: Toy patch to lua. It keeps the table length as an field of the C table struc. It is based on the Lua repo, as seen by the Lua team. · GitHub
Skip to content
 
 

Latest commit

 

History

4,989 Commits

Folders and files

Repository files navigation

This is thoughtless-patch to lua that keeps a length field in the C struct of the table. It behaves as the following:

  • A length is kept in a new field of the table struct (intialized to 0)
  • Length-operator/opcode return it
  • The length is changed every time something is written in t[#t+1] (nil also).
  • ipairs loops from 1 to this length, also if there are holes
  • The table.setlen function can be used to set the value of the new field. It does not change anything else.

The execution time increases by ~1% (when updating the length) while the memory size increases by ~8% (when storing empty tables).

About

Toy patch to lua. It keeps the table length as an field of the C table struc. It is based on the Lua repo, as seen by the Lua team.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages