Pass argument by value to CFDF_Document::ParseStream().
Avoids a spurious clang-tidy warning, but is more efficient since
we can move twice and avoid ref-churn. Generally, if a routine is
going to stash away a RetainPtr<>, passing by value and then moving
is a win because the caller might already have an rvalue.
Change-Id: I15bf4ab201d0752ff1ed358ce823629b2156cc81
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52510
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index d0cf638..739fefa 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -35,9 +35,8 @@
return pDoc->m_pRootDict ? std::move(pDoc) : nullptr;
}
-void CFDF_Document::ParseStream(
- const RetainPtr<IFX_SeekableReadStream>& pFile) {
- m_pFile = pFile;
+void CFDF_Document::ParseStream(RetainPtr<IFX_SeekableReadStream> pFile) {
+ m_pFile = std::move(pFile);
CPDF_SyntaxParser parser(m_pFile);
while (1) {
bool bNumber;
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h
index 55871e7..3c93a5e 100644
--- a/core/fpdfapi/parser/cfdf_document.h
+++ b/core/fpdfapi/parser/cfdf_document.h
@@ -29,7 +29,7 @@
CPDF_Dictionary* GetRoot() const { return m_pRootDict.Get(); }
private:
- void ParseStream(const RetainPtr<IFX_SeekableReadStream>& pFile);
+ void ParseStream(RetainPtr<IFX_SeekableReadStream> pFile);
UnownedPtr<CPDF_Dictionary> m_pRootDict;
RetainPtr<IFX_SeekableReadStream> m_pFile;