Commit 31073ea358b7934538b166211cceb1858cc4f4d5

Authored by m-holger
1 parent 7e7cede8

Refactor `is::OffsetBuffer` to introduce overloaded constructor, reducing redund…

…ancy and improving initialization consistency.
libqpdf/qpdf/InputSource_private.hh
@@ -13,13 +13,12 @@ namespace qpdf::is @@ -13,13 +13,12 @@ namespace qpdf::is
13 class OffsetBuffer final: public InputSource 13 class OffsetBuffer final: public InputSource
14 { 14 {
15 public: 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 description(description), 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 global_offset(global_offset) 22 global_offset(global_offset)
24 { 23 {
25 if (global_offset < 0) { 24 if (global_offset < 0) {
@@ -28,6 +27,17 @@ namespace qpdf::is @@ -28,6 +27,17 @@ namespace qpdf::is
28 last_offset = global_offset; 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 ~OffsetBuffer() final = default; 41 ~OffsetBuffer() final = default;
32 42
33 qpdf_offset_t findAndSkipNextEOL() final; 43 qpdf_offset_t findAndSkipNextEOL() final;