diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-24 15:05:50 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-24 15:05:50 +0200 |
commit | 4925f0d18c5554bf96d8cb853b5a017e0d18fda2 (patch) | |
tree | 0be25169d5fe7b306b9a8b84bb8f300f96869342 | |
parent | 68e721981a1fe4f1398d811bb8ed99af0e100da8 (diff) | |
download | qpdf-4925f0d18c5554bf96d8cb853b5a017e0d18fda2.tar.zst |
Have dictionary/streams mutators take const& where possible
-rw-r--r-- | include/qpdf/QPDFObjectHandle.hh | 6 | ||||
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 7 | ||||
-rw-r--r-- | libqpdf/QPDF_Dictionary.cc | 3 | ||||
-rw-r--r-- | libqpdf/QPDF_Stream.cc | 4 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Dictionary.hh | 2 | ||||
-rw-r--r-- | libqpdf/qpdf/QPDF_Stream.hh | 2 |
6 files changed, 13 insertions, 11 deletions
diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 5b2a6764..ffffe523 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -1025,13 +1025,13 @@ class QPDFObjectHandle // Replace value of key, adding it if it does not exist QPDF_DLL - void replaceKey(std::string const& key, QPDFObjectHandle); + void replaceKey(std::string const& key, QPDFObjectHandle const&); // Remove key, doing nothing if key does not exist QPDF_DLL void removeKey(std::string const& key); // If the object is null, remove the key. Otherwise, replace it. QPDF_DLL - void replaceOrRemoveKey(std::string const& key, QPDFObjectHandle); + void replaceOrRemoveKey(std::string const& key, QPDFObjectHandle const&); // Methods for stream objects QPDF_DLL @@ -1164,7 +1164,7 @@ class QPDFObjectHandle // may be more convenient in this case than calling getDict and // modifying it for each key. The pdf-create example does this. QPDF_DLL - void replaceDict(QPDFObjectHandle); + void replaceDict(QPDFObjectHandle const&); // Replace this stream's stream data with the given data buffer, // and replace the /Filter and /DecodeParms keys in the stream diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 9fadbef3..516e38b9 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -1268,7 +1268,8 @@ QPDFObjectHandle::getOwningQPDF() // Dictionary mutators void -QPDFObjectHandle::replaceKey(std::string const& key, QPDFObjectHandle value) +QPDFObjectHandle::replaceKey( + std::string const& key, QPDFObjectHandle const& value) { if (isDictionary()) { checkOwnership(value); @@ -1292,7 +1293,7 @@ QPDFObjectHandle::removeKey(std::string const& key) void QPDFObjectHandle::replaceOrRemoveKey( - std::string const& key, QPDFObjectHandle value) + std::string const& key, QPDFObjectHandle const& value) { if (isDictionary()) { checkOwnership(value); @@ -1334,7 +1335,7 @@ QPDFObjectHandle::isDataModified() } void -QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict) +QPDFObjectHandle::replaceDict(QPDFObjectHandle const& new_dict) { assertStream(); dynamic_cast<QPDF_Stream*>(obj.get())->replaceDict(new_dict); diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 599f7224..1655f53a 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -115,7 +115,8 @@ QPDF_Dictionary::getAsMap() const } void -QPDF_Dictionary::replaceKey(std::string const& key, QPDFObjectHandle value) +QPDF_Dictionary::replaceKey( + std::string const& key, QPDFObjectHandle const& value) { // add or replace value this->items[key] = value; diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index c36b7725..cbc65611 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -617,11 +617,11 @@ QPDF_Stream::replaceFilterData( } void -QPDF_Stream::replaceDict(QPDFObjectHandle new_dict) +QPDF_Stream::replaceDict(QPDFObjectHandle const& new_dict) { this->stream_dict = new_dict; setDictDescription(); - QPDFObjectHandle length_obj = new_dict.getKey("/Length"); + QPDFObjectHandle length_obj = this->stream_dict.getKey("/Length"); if (length_obj.isInteger()) { this->length = QIntC::to_size(length_obj.getUIntValue()); } else { diff --git a/libqpdf/qpdf/QPDF_Dictionary.hh b/libqpdf/qpdf/QPDF_Dictionary.hh index 8626d59b..42ee6cf9 100644 --- a/libqpdf/qpdf/QPDF_Dictionary.hh +++ b/libqpdf/qpdf/QPDF_Dictionary.hh @@ -28,7 +28,7 @@ class QPDF_Dictionary: public QPDFObject std::map<std::string, QPDFObjectHandle> const& getAsMap() const; // Replace value of key, adding it if it does not exist - void replaceKey(std::string const& key, QPDFObjectHandle); + void replaceKey(std::string const& key, QPDFObjectHandle const&); // Remove key, doing nothing if key does not exist void removeKey(std::string const& key); // If object is null, remove key; otherwise, replace key diff --git a/libqpdf/qpdf/QPDF_Stream.hh b/libqpdf/qpdf/QPDF_Stream.hh index a6ee9551..ba456e76 100644 --- a/libqpdf/qpdf/QPDF_Stream.hh +++ b/libqpdf/qpdf/QPDF_Stream.hh @@ -62,7 +62,7 @@ class QPDF_Stream: public QPDFObject void addTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter); - void replaceDict(QPDFObjectHandle new_dict); + void replaceDict(QPDFObjectHandle const& new_dict); static void registerStreamFilter( std::string const& filter_name, |