@@ -101,7 +101,9 @@ struct CompositeWorker : Nan::AsyncWorker
101
101
int const target_x = baton_data_->x ;
102
102
int const target_y = baton_data_->y ;
103
103
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;
105
107
106
108
for (auto const & tile_obj : baton_data_->tiles )
107
109
{
@@ -110,10 +112,10 @@ struct CompositeWorker : Nan::AsyncWorker
110
112
vtzero::data_view tile_view{};
111
113
if (gzip::is_compressed (tile_obj->data .data (), tile_obj->data .size ()))
112
114
{
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 };
117
119
}
118
120
else
119
121
{
@@ -166,7 +168,7 @@ struct CompositeWorker : Nan::AsyncWorker
166
168
{
167
169
std::string temp;
168
170
builder.serialize (temp);
169
- tile_buffer = gzip:: compress (temp.data (), temp.size ());
171
+ compressor. compress (tile_buffer, temp.data (), temp.size ());
170
172
}
171
173
else
172
174
{
0 commit comments