Skip to content

Commit c563018

Browse files
author
Dane Springmeyer
committed
start porting to libdeflate - mapbox/gzip-hpp#25
1 parent 774f53d commit c563018

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

binding.gyp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
],
9595
'xcode_settings': {
9696
'OTHER_LDFLAGS':[
97-
'-Wl,-bind_at_load'
97+
'-Wl,-bind_at_load',
98+
'<(module_root_dir)/mason_packages/.link/lib/libdeflate.a'
9899
],
99100
'OTHER_CPLUSPLUSFLAGS': [
100101
'<@(system_includes)',

src/vtcomposite.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ struct CompositeWorker : Nan::AsyncWorker
101101
int const target_x = baton_data_->x;
102102
int const target_y = baton_data_->y;
103103

104-
std::vector<std::unique_ptr<std::vector<char>>> buffer_cache;
104+
std::vector<std::string> buffer_cache;
105+
gzip::Decompressor decompressor;
106+
gzip::Compressor compressor;
105107

106108
for (auto const& tile_obj : baton_data_->tiles)
107109
{
@@ -110,10 +112,10 @@ struct CompositeWorker : Nan::AsyncWorker
110112
vtzero::data_view tile_view{};
111113
if (gzip::is_compressed(tile_obj->data.data(), tile_obj->data.size()))
112114
{
113-
buffer_cache.push_back(std::make_unique<std::vector<char>>());
114-
gzip::Decompressor decompressor;
115-
decompressor.decompress(*buffer_cache.back(), tile_obj->data.data(), tile_obj->data.size());
116-
tile_view = protozero::data_view{buffer_cache.back()->data(), buffer_cache.back()->size()};
115+
buffer_cache.emplace_back();
116+
std::string & buf = buffer_cache.back();
117+
decompressor.decompress(buf, tile_obj->data.data(), tile_obj->data.size());
118+
tile_view = vtzero::data_view{buf};
117119
}
118120
else
119121
{
@@ -166,7 +168,7 @@ struct CompositeWorker : Nan::AsyncWorker
166168
{
167169
std::string temp;
168170
builder.serialize(temp);
169-
tile_buffer = gzip::compress(temp.data(), temp.size());
171+
compressor.compress(tile_buffer, temp.data(), temp.size());
170172
}
171173
else
172174
{

0 commit comments

Comments
 (0)