Commit 680b68747e2a8226052397dfaefd62fa5940dfb8
1 parent
1457c421
Refactor linearization hint stream logic in `QPDF_linearization.cc` to simplify …
…buffer handling and streamline compression.
Showing
1 changed file
with
7 additions
and
10 deletions
libqpdf/QPDF_linearization.cc
| ... | ... | @@ -1753,21 +1753,18 @@ QPDF::generateHintStream( |
| 1753 | 1753 | |
| 1754 | 1754 | // Write the hint stream itself into a compressed memory buffer. Write through a counter so we |
| 1755 | 1755 | // can get offsets. |
| 1756 | - std::string b; | |
| 1757 | - auto c = compressed | |
| 1758 | - ? std::make_unique<pl::Count>( | |
| 1759 | - 0, b, pl::create<Pl_Flate>(pl::create<pl::String>(hint_buffer), Pl_Flate::a_deflate)) | |
| 1760 | - : std::make_unique<pl::Count>(0, hint_buffer); | |
| 1761 | - | |
| 1762 | - BitWriter w(c.get()); | |
| 1756 | + pl::Count c(0, hint_buffer); | |
| 1757 | + BitWriter w(&c); | |
| 1763 | 1758 | |
| 1764 | 1759 | writeHPageOffset(w); |
| 1765 | - S = toI(c->getCount()); | |
| 1760 | + S = toI(c.getCount()); | |
| 1766 | 1761 | writeHSharedObject(w); |
| 1767 | 1762 | O = 0; |
| 1768 | 1763 | if (m->outline_hints.nobjects > 0) { |
| 1769 | - O = toI(c->getCount()); | |
| 1764 | + O = toI(c.getCount()); | |
| 1770 | 1765 | writeHGeneric(w, m->outline_hints); |
| 1771 | 1766 | } |
| 1772 | - c->finish(); | |
| 1767 | + if (compressed) { | |
| 1768 | + hint_buffer = pl::pipe<Pl_Flate>(hint_buffer, Pl_Flate::a_deflate); | |
| 1769 | + } | |
| 1773 | 1770 | } | ... | ... |