Commit 31073ea358b7934538b166211cceb1858cc4f4d5
1 parent
7e7cede8
Refactor `is::OffsetBuffer` to introduce overloaded constructor, reducing redund…
…ancy and improving initialization consistency.
Showing
1 changed file
with
16 additions
and
6 deletions
libqpdf/qpdf/InputSource_private.hh
| ... | ... | @@ -13,13 +13,12 @@ namespace qpdf::is |
| 13 | 13 | class OffsetBuffer final: public InputSource |
| 14 | 14 | { |
| 15 | 15 | public: |
| 16 | - OffsetBuffer(std::string const& description, Buffer* buf, qpdf_offset_t global_offset) : | |
| 16 | + OffsetBuffer( | |
| 17 | + std::string const& description, | |
| 18 | + std::string_view view, | |
| 19 | + qpdf_offset_t global_offset = 0) : | |
| 17 | 20 | description(description), |
| 18 | - view_( | |
| 19 | - buf && buf->getSize() | |
| 20 | - ? std::string_view( | |
| 21 | - reinterpret_cast<const char*>(buf->getBuffer()), buf->getSize()) | |
| 22 | - : std::string_view()), | |
| 21 | + view_(view), | |
| 23 | 22 | global_offset(global_offset) |
| 24 | 23 | { |
| 25 | 24 | if (global_offset < 0) { |
| ... | ... | @@ -28,6 +27,17 @@ namespace qpdf::is |
| 28 | 27 | last_offset = global_offset; |
| 29 | 28 | } |
| 30 | 29 | |
| 30 | + OffsetBuffer(std::string const& description, Buffer* buf, qpdf_offset_t global_offset = 0) : | |
| 31 | + OffsetBuffer( | |
| 32 | + description, | |
| 33 | + {buf && buf->getSize() | |
| 34 | + ? std::string_view( | |
| 35 | + reinterpret_cast<const char*>(buf->getBuffer()), buf->getSize()) | |
| 36 | + : std::string_view()}, | |
| 37 | + global_offset) | |
| 38 | + { | |
| 39 | + } | |
| 40 | + | |
| 31 | 41 | ~OffsetBuffer() final = default; |
| 32 | 42 | |
| 33 | 43 | qpdf_offset_t findAndSkipNextEOL() final; | ... | ... |