lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Actually that is quite easy by just creating a table of numbers:
> 
> return {1,2,3,4,5,6,7,8,9,0,1,6,3,2,2,2,4,6,7,2,7,8,3}
> 
> As Lua bytecode stores all numbers as doubles (by default) the source 
> code will be smaller as long as the numbers have less then 8 digits.

This example works specially well because the Lua compiler performs
constant optimizations and so stores only one copy of each constant
in the bytecode.

Another source of size in precompiled scripts is debug information,
specially line numbers, which are stored as an array of ints, one for
each instruction. Stripping precompiled scripts with luac -s removes
this information and more.