-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for zlib compression with miniz (#163) #165
Add support for zlib compression with miniz (#163) #165
Conversation
src/lminiz.c
Outdated
static int lmz_deflator_init(lua_State* L) { | ||
int level = luaL_optint(L, 1, MZ_DEFAULT_COMPRESSION); | ||
if (level < MZ_DEFAULT_COMPRESSION || level > MZ_BEST_COMPRESSION) { | ||
luaL_error(L, "Compression level must be between -1 and 9"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure everything uses 2 space indentations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, there goes KDevelop reindenting my code 😛
return 0; | ||
} | ||
|
||
static const char* flush_types[] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lua requires a string array for luaL_checkopt, which is where this is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to use optint to stay consistent with inflate and deflate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those functions appear to use an integer because it's a bitfield, rather than an enumeration. Personally, I think using a string is more favourable here but I will gladly change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess either works.
How much does this increase the binary size? |
With the patch, binary size is increased by exactly 8 KiB on my machine. |
I know that zlib can optionally be used in luvi, but I was hoping that we could make the most out of miniz since it's included by default. I didn't realize that parts of it were disabled to keep the file size small. |
8kb is probably fine. Especially if it enables more apps to use the tiny version of luvi. |
This allows users of luvi to use zlib compression without the zlib module, meaning that it is technically no longer necessary. This has been tested on Debian buster (current testing) on a 64-bit AMD processor, where it appears to work correctly. I expect it to work correctly on all current targets.
1379d0d
to
ec0c05c
Compare
This allows users of luvi to use zlib compression without the zlib module, meaning that it is technically no longer necessary.
This has been tested on Debian buster (current testing) on a 64-bit AMD processor, where it appears to work correctly. I expect it to work correctly on all current targets.
I believe I have followed the style of code in my edits, though I will gladly fix any issues that are pointed out.
The API looks something like this, using the example of a deflator: