From 31073ea358b7934538b166211cceb1858cc4f4d5 Mon Sep 17 00:00:00 2001 From: m-holger Date: Wed, 4 Jun 2025 14:02:44 +0100 Subject: [PATCH] Refactor `is::OffsetBuffer` to introduce overloaded constructor, reducing redundancy and improving initialization consistency. --- libqpdf/qpdf/InputSource_private.hh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/libqpdf/qpdf/InputSource_private.hh b/libqpdf/qpdf/InputSource_private.hh index a52bcb3..7732ea1 100644 --- a/libqpdf/qpdf/InputSource_private.hh +++ b/libqpdf/qpdf/InputSource_private.hh @@ -13,13 +13,12 @@ namespace qpdf::is class OffsetBuffer final: public InputSource { public: - OffsetBuffer(std::string const& description, Buffer* buf, qpdf_offset_t global_offset) : + OffsetBuffer( + std::string const& description, + std::string_view view, + qpdf_offset_t global_offset = 0) : description(description), - view_( - buf && buf->getSize() - ? std::string_view( - reinterpret_cast(buf->getBuffer()), buf->getSize()) - : std::string_view()), + view_(view), global_offset(global_offset) { if (global_offset < 0) { @@ -28,6 +27,17 @@ namespace qpdf::is last_offset = global_offset; } + OffsetBuffer(std::string const& description, Buffer* buf, qpdf_offset_t global_offset = 0) : + OffsetBuffer( + description, + {buf && buf->getSize() + ? std::string_view( + reinterpret_cast(buf->getBuffer()), buf->getSize()) + : std::string_view()}, + global_offset) + { + } + ~OffsetBuffer() final = default; qpdf_offset_t findAndSkipNextEOL() final; -- libgit2 0.21.4