deps: update zlib to 1.3.0.1-motley-71660e1 by nodejs-github-bot · Pull Request #53464 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions deps/zlib/CMakeLists.txt
20 changes: 6 additions & 14 deletions deps/zlib/contrib/bench/zlib_bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ Data read_file_data_or_exit(const char* name) {
return data;
}

size_t zlib_estimate_compressed_size(size_t input_size) {
return compressBound(input_size);
}

enum zlib_wrapper {
kWrapperNONE,
kWrapperZLIB,
Expand Down Expand Up @@ -128,10 +124,6 @@ void zlib_compress(
std::string* output,
bool resize_output = false)
{
if (resize_output)
output->resize(zlib_estimate_compressed_size(input_size));
size_t output_size = output->size();

z_stream stream;
memset(&stream, 0, sizeof(stream));

Expand All @@ -140,6 +132,11 @@ void zlib_compress(
if (result != Z_OK)
error_exit("deflateInit2 failed", result);

if (resize_output) {
output->resize(deflateBound(&stream, input_size));
}
size_t output_size = output->size();

stream.next_out = (Bytef*)string_data(output);
stream.avail_out = (uInt)output_size;
stream.next_in = (z_const Bytef*)input;
Expand Down Expand Up @@ -299,19 +296,14 @@ void zlib_file(const char* name,

// Pre-grow the output buffer so we don't measure string resize time.
for (int b = 0; b < blocks; ++b)
compressed[b].resize(zlib_estimate_compressed_size(block_size));
zlib_compress(type, input[b], input_length[b], &compressed[b], true);

auto start = now();
for (int b = 0; b < blocks; ++b)
for (int r = 0; r < repeats; ++r)
zlib_compress(type, input[b], input_length[b], &compressed[b]);
ctime[run] = std::chrono::duration<double>(now() - start).count();

// Compress again, resizing compressed, so we don't leave junk at the
// end of the compressed string that could confuse zlib_uncompress().
for (int b = 0; b < blocks; ++b)
zlib_compress(type, input[b], input_length[b], &compressed[b], true);

for (int b = 0; b < blocks; ++b)
output[b].resize(input_length[b]);

Expand Down
3 changes: 2 additions & 1 deletion deps/zlib/contrib/minizip/README.chromium
Loading