diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc index 6a1525d..fa2562c 100644 --- a/libqpdf/QPDFParser.cc +++ b/libqpdf/QPDFParser.cc @@ -404,7 +404,7 @@ QPDFParser::parse(bool& empty, bool content_stream) QPDFObjectHandle::newString(frame.contents_string); dict["/Contents"].setParsedOffset(frame.contents_offset); } - object = QPDF_Dictionary::create(dict); + object = QPDF_Dictionary::create(std::move(dict)); setDescription(object, offset - 2); // The `offset` points to the next of "<<". Set the rewind // offset to point to the beginning of "<<". This has been diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 87d93a3..5349a2a 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -9,6 +9,13 @@ QPDF_Dictionary::QPDF_Dictionary( { } +QPDF_Dictionary::QPDF_Dictionary( + std::map&& items) : + QPDFValue(::ot_dictionary, "dictionary"), + items(items) +{ +} + std::shared_ptr QPDF_Dictionary::create(std::map const& items) { @@ -16,6 +23,12 @@ QPDF_Dictionary::create(std::map const& items) } std::shared_ptr +QPDF_Dictionary::create(std::map&& items) +{ + return do_create(new QPDF_Dictionary(items)); +} + +std::shared_ptr QPDF_Dictionary::copy(bool shallow) { if (shallow) { diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh index 3354a25..bc02540 100644 --- a/libqpdf/qpdf/QPDF_Dictionary.hh +++ b/libqpdf/qpdf/QPDF_Dictionary.hh @@ -14,6 +14,8 @@ class QPDF_Dictionary: public QPDFValue virtual ~QPDF_Dictionary() = default; static std::shared_ptr create(std::map const& items); + static std::shared_ptr + create(std::map&& items); virtual std::shared_ptr copy(bool shallow = false); virtual std::string unparse(); virtual JSON getJSON(int json_version); @@ -35,6 +37,7 @@ class QPDF_Dictionary: public QPDFValue private: QPDF_Dictionary(std::map const& items); + QPDF_Dictionary(std::map&& items); std::map items; };