From 7ac9a08615dc71ad4493f4d963a012f31738ecc2 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sun, 7 Dec 2025 16:32:31 +0000 Subject: [PATCH] Refactor `FormNode::generateTextAppearance`: Simplifyby using range-based `for` loop --- libqpdf/QPDFFormFieldObjectHelper.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc index 0e8ebd5..dafd89c 100644 --- a/libqpdf/QPDFFormFieldObjectHelper.cc +++ b/libqpdf/QPDFFormFieldObjectHelper.cc @@ -877,7 +877,6 @@ namespace }; } // namespace - void FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) { @@ -914,7 +913,7 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) // and updating it could have unintended side effects. This threshold may need to be updated // if the internal reference counting changes in the future. // - // There is currently no explicit CI test for this code> I has been manually tested bu + // There is currently no explicit CI test for this code. It has been manually tested by // running it through CI with a threshold of 0, unconditionally copying streams. auto data = AS.getStreamData(qpdf_dl_all); AS = AS.copy(); @@ -934,10 +933,6 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle(); std::string DA = default_appearance(); std::string V = value(); - std::vector opt; - if (isChoice() && (getFlags() & ff_ch_combo) == 0) { - opt = getChoices(); - } TfFinder tff; Pl_QPDFTokenizer tok("tf", &tff); @@ -976,8 +971,13 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh) } V = (*encoder)(V, '?'); - for (size_t i = 0; i < opt.size(); ++i) { - opt.at(i) = (*encoder)(opt.at(i), '?'); + + std::vector opt; + if (isChoice() && (getFlags() & ff_ch_combo) == 0) { + opt = getChoices(); + for (auto& o: opt) { + o = (*encoder)(o, '?'); + } } std::string result; -- libgit2 0.21.4