From 4278a55752943c16430c6625c123765e5648892d Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 19 Jul 2025 18:40:59 +0100 Subject: [PATCH] Refactor `QPDFWriter` to replace `pl::Link` with direct use of `Pipeline` for improved clarity and reduced indirection in pipeline management. --- libqpdf/QPDFWriter.cc | 14 +++++++------- libqpdf/qpdf/Pipeline_private.hh | 12 +----------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index ba52fd9..59f4075 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -141,20 +141,20 @@ namespace } void - activate(Popper& pp, std::unique_ptr link) + activate(Popper& pp, std::unique_ptr next) { count_buffer.clear(); - activate(pp, false, &count_buffer, std::move(link)); + activate(pp, false, &count_buffer, std::move(next)); } Popper activate( bool discard = false, std::string* str = nullptr, - std::unique_ptr link = nullptr) + std::unique_ptr next = nullptr) { Popper pp{*this}; - activate(pp, discard, str, std::move(link)); + activate(pp, discard, str, std::move(next)); return pp; } @@ -163,11 +163,11 @@ namespace Popper& pp, bool discard = false, std::string* str = nullptr, - std::unique_ptr link = nullptr) + std::unique_ptr next = nullptr) { std::unique_ptr c; - if (link) { - c = std::make_unique(++last_id, count_buffer, std::move(link)); + if (next) { + c = std::make_unique(++last_id, count_buffer, std::move(next)); } else if (discard) { c = std::make_unique(++last_id, nullptr); } else if (!str) { diff --git a/libqpdf/qpdf/Pipeline_private.hh b/libqpdf/qpdf/Pipeline_private.hh index c19dd41..eecae0c 100644 --- a/libqpdf/qpdf/Pipeline_private.hh +++ b/libqpdf/qpdf/Pipeline_private.hh @@ -54,20 +54,10 @@ namespace qpdf::pl { } - // Count the number of characters written. If 'next' is not set, the content written will be - // discarded. - Count(unsigned long id, std::unique_ptr link) : - Pipeline("", link ? link.get() : nullptr), - link(std::move(link)), - id_(id), - pass_immediately_to_next(link) - { - } - // Write to 'str'. If 'next' is set, 'str' will be written to 'next' when 'finish' is // called. Count(unsigned long id, std::string& str, std::unique_ptr link = nullptr) : - Pipeline("", link ? link.get() : nullptr), + Pipeline("", link.get()), str(&str), link(std::move(link)), id_(id) -- libgit2 0.21.4