On 06/18/2014 12:50 PM, Paige DePol wrote:
On Jun 17, 2014, at 9:27 PM, Sean Conner <sean@conman.org> wrote:
Do note that the compiled Lua script may not necessarily be smaller than
Lua source code. Also, I've found that compressed Lua scripts are smaller
than compressed compiled Lua scripts (using zlib---it's not a hard library
to use and there are Lua wrappers for it).
-spc
Do you have an example of a Lua script that results in a larger compiled file vs source file? I am curious to see how that could happen. I would think that having a script compile and be larger would be a fairly uncommon occurrence.
I can see how compressed source could be smaller than compressed compiled source, though on a restricted system that would just add additional memory and processing overhead for decompression. The idea was to skip parsing altogether and just load binary scripts, leaving the possibility of removing the parser from the library, which is a 35% reduction in the size of the Lua core according to Luiz.
~pmd
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.
--
Thomas