Add -b and -g, for creating bytecode before compile#20
Add -b and -g, for creating bytecode before compile#20Frityet wants to merge 1 commit intohugomg:masterfrom
-b and -g, for creating bytecode before compile#20Conversation
|
I would have hoped that compiling to bytecode would reduce the binary size. Since it doesn't, maybe it would be simpler to just strip the shebangs from the source string? |
it does sometimes, ive had much much better binary sizes with larger files. Another good reason to use bytecode is obsufication. With the string you can get the full lua source which could be not desired. |
| ``` | ||
|
|
||
| ### `-b`, `-g` | ||
| `-b` precompiles the lua source into bytecode before including it in the binary. By default, it strips symbols from the bytecode, but you can keep symbols with `-g`: |
There was a problem hiding this comment.
It wouldn't hurt to say that -b saves space for large files
| int bytecode_writer(lua_State *L, const void *p, size_t sz, void *ud) | ||
| { | ||
| (void)L; | ||
| luaL_Buffer *b = (luaL_Buffer *)ud; |
There was a problem hiding this comment.
In C, we don't need to write an explicit cast for a void*. I think it would suffice to say
luaL_Buffer *b = ud;
Also, I think we can also add a line for
const char *bytes = p
(I expect that we don't need to say "unsigned")
There was a problem hiding this comment.
In C, we don't need to write an explicit cast for a void*. I think it would suffice to say
yeah that was a holdover when I had my own struct, accident! Thanks.
Also, I think we can also add a line for
Will do
| if (precompile) | ||
| print_source_code_bytecode(L); | ||
| else | ||
| print_source_code_source(L); |
There was a problem hiding this comment.
Please use braces around the if/else bodies.
|
Also, could you please tell some more about your experience with -b and -g?
|
ill show benchmarks, give me a couple of days |
Fixes #19