Commit 47cf4e3a50e8bdc392a68dcf11a15ccb6a348df0
1 parent
2fa93e79
In QPDFWriter change object_stream_to_objects to a map of vectors.
Showing
2 changed files
with
9 additions
and
7 deletions
libqpdf/QPDFWriter.cc
| @@ -2179,12 +2179,14 @@ QPDFWriter::doWriteSetup() | @@ -2179,12 +2179,14 @@ QPDFWriter::doWriteSetup() | ||
| 2179 | // Generate reverse mapping from object stream to objects | 2179 | // Generate reverse mapping from object stream to objects |
| 2180 | m->obj.forEach([this](auto id, auto const& item) -> void { | 2180 | m->obj.forEach([this](auto id, auto const& item) -> void { |
| 2181 | if (item.object_stream > 0) { | 2181 | if (item.object_stream > 0) { |
| 2182 | - m->object_stream_to_objects[item.object_stream].insert(QPDFObjGen(id, item.gen)); | ||
| 2183 | - m->max_ostream_index = std::max( | ||
| 2184 | - m->max_ostream_index, | ||
| 2185 | - QIntC::to_int(m->object_stream_to_objects[item.object_stream].size()) - 1); | 2182 | + auto& vec = m->object_stream_to_objects[item.object_stream]; |
| 2183 | + vec.emplace_back(id, item.gen); | ||
| 2184 | + if (m->max_ostream_index < vec.size()) { | ||
| 2185 | + ++m->max_ostream_index; | ||
| 2186 | + } | ||
| 2186 | } | 2187 | } |
| 2187 | }); | 2188 | }); |
| 2189 | + --m->max_ostream_index; | ||
| 2188 | 2190 | ||
| 2189 | if (m->object_stream_to_objects.empty()) { | 2191 | if (m->object_stream_to_objects.empty()) { |
| 2190 | m->obj.streams_empty = true; | 2192 | m->obj.streams_empty = true; |
| @@ -2431,7 +2433,7 @@ QPDFWriter::writeXRefStream( | @@ -2431,7 +2433,7 @@ QPDFWriter::writeXRefStream( | ||
| 2431 | unsigned int f1_size = std::max(bytesNeeded(max_offset + hint_length), bytesNeeded(max_id)); | 2433 | unsigned int f1_size = std::max(bytesNeeded(max_offset + hint_length), bytesNeeded(max_id)); |
| 2432 | 2434 | ||
| 2433 | // field 2 contains object stream indices | 2435 | // field 2 contains object stream indices |
| 2434 | - unsigned int f2_size = bytesNeeded(m->max_ostream_index); | 2436 | + unsigned int f2_size = bytesNeeded(QIntC::to_longlong(m->max_ostream_index)); |
| 2435 | 2437 | ||
| 2436 | unsigned int esize = 1 + f1_size + f2_size; | 2438 | unsigned int esize = 1 + f1_size + f2_size; |
| 2437 | 2439 |
libqpdf/qpdf/QPDFWriter_private.hh
| @@ -97,11 +97,11 @@ class QPDFWriter::Members | @@ -97,11 +97,11 @@ class QPDFWriter::Members | ||
| 97 | int cur_stream_length_id{0}; | 97 | int cur_stream_length_id{0}; |
| 98 | size_t cur_stream_length{0}; | 98 | size_t cur_stream_length{0}; |
| 99 | bool added_newline{false}; | 99 | bool added_newline{false}; |
| 100 | - int max_ostream_index{0}; | 100 | + size_t max_ostream_index{0}; |
| 101 | std::set<QPDFObjGen> normalized_streams; | 101 | std::set<QPDFObjGen> normalized_streams; |
| 102 | std::map<QPDFObjGen, int> page_object_to_seq; | 102 | std::map<QPDFObjGen, int> page_object_to_seq; |
| 103 | std::map<QPDFObjGen, int> contents_to_page_seq; | 103 | std::map<QPDFObjGen, int> contents_to_page_seq; |
| 104 | - std::map<int, std::set<QPDFObjGen>> object_stream_to_objects; | 104 | + std::map<int, std::vector<QPDFObjGen>> object_stream_to_objects; |
| 105 | std::list<Pipeline*> pipeline_stack; | 105 | std::list<Pipeline*> pipeline_stack; |
| 106 | unsigned long long next_stack_id{0}; | 106 | unsigned long long next_stack_id{0}; |
| 107 | bool deterministic_id{false}; | 107 | bool deterministic_id{false}; |