-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Description
I looked at the code and have some comments:
- https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/compress.hpp#L27 That's confusing: The
output
parameter is of typeInputType
? And I would have expected the output parameter to come after the input parameters. But that's historically inconsistent in C APIs anyway... - Not sure we need the
Compressor
andDecompressor
classes. The only thing that ever happens to them is that they are instantiated and then the(de)compress
function is called on them. That would work as a simple function? I can see why this might be useful when we (de)compress in blocks, but the library can't do that due to theinflateInit2
anddeflateInit2
functions not being in the constructor. Okay, we don't have to set those compression parameters every time, but how often do we re-use an instantiatedCompressor
orDecompressor
object to make this useful? - Useless SECTION: https://github.com/mapbox/gzip-hpp/blob/master/test/test_io.cpp#L12
- https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/utils.hpp#L8 can be
noexcept
and the function is hard to follow due the many parentheses. - https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/compress.hpp#L32-L38 Consider using
assert()
here. - There should be helper functions like
(de)compress()
that take an existingstd::string
and fill it. - https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/decompress.hpp#L64 If the second condition is true, the first is also true, so this can be simplified.
- https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/decompress.hpp#L57 I don't think this is correct. If
std::size
is 32bitsize * 2
will be 32bit and can overflow before it is assigned to the 64bitsize_64
.const auto size_64 = static_cast<uint64_t>(size) * 2;
should be correct. - There are several places where
inflateEnd
is called (like here https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/decompress.hpp#L60). Maybe this can be wrapped in an RAII wrapper somehow? - If we have gzipped-compressed data, the header can tell us how large the uncompressed data was. Can we use this to optimize this case and have the output buffer in the correct size from the beginning?
- https://github.com/mapbox/gzip-hpp/blob/master/include/gzip/decompress.hpp#L55-L63 this can be moved above the
inflateInit2
call saving aninflateEnd
. Also consider making this anassert
.
GretaCB
Metadata
Metadata
Assignees
Labels
No labels