From e005dc33c31a2e701e1af3a0a3e5775cabbf1ddd Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 19 Jun 2018 17:33:32 +0000 Subject: Move fxcrt::{Byte,Wide}Strings with std::move(). Remove some string copies in barcode that were noticed whilst looking for moves. Change-Id: Ieda34d00f633576ba1f0dca283dcdabfb36f236c Reviewed-on: https://pdfium-review.googlesource.com/35410 Reviewed-by: dsinclair Reviewed-by: Tom Sepez Commit-Queue: Tom Sepez --- core/fpdfapi/page/cpdf_contentmark.cpp | 8 ++++---- core/fpdfapi/page/cpdf_contentmark.h | 6 ++---- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp index e17a30560f..deddf3cc3e 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -31,10 +31,10 @@ int CPDF_ContentMark::GetMarkedContentID() const { return pData ? pData->GetMarkedContentID() : -1; } -void CPDF_ContentMark::AddMark(const ByteString& name, +void CPDF_ContentMark::AddMark(ByteString name, const CPDF_Dictionary* pDict, bool bDirect) { - m_Ref.GetPrivateCopy()->AddMark(name, pDict, bDirect); + m_Ref.GetPrivateCopy()->AddMark(std::move(name), pDict, bDirect); } void CPDF_ContentMark::DeleteLastMark() { @@ -68,11 +68,11 @@ int CPDF_ContentMark::MarkData::GetMarkedContentID() const { return -1; } -void CPDF_ContentMark::MarkData::AddMark(const ByteString& name, +void CPDF_ContentMark::MarkData::AddMark(ByteString name, const CPDF_Dictionary* pDict, bool bDirect) { CPDF_ContentMarkItem item; - item.SetName(name); + item.SetName(std::move(name)); if (pDict) { if (bDirect) item.SetDirectDict(ToDictionary(pDict->Clone())); diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index 1d8b9e2515..494c20630b 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -25,9 +25,7 @@ class CPDF_ContentMark { size_t CountItems() const; const CPDF_ContentMarkItem& GetItem(size_t i) const; - void AddMark(const ByteString& name, - const CPDF_Dictionary* pDict, - bool bDirect); + void AddMark(ByteString name, const CPDF_Dictionary* pDict, bool bDirect); void DeleteLastMark(); bool HasRef() const { return !!m_Ref; } @@ -43,7 +41,7 @@ class CPDF_ContentMark { const CPDF_ContentMarkItem& GetItem(size_t index) const; int GetMarkedContentID() const; - void AddMark(const ByteString& name, + void AddMark(ByteString name, const CPDF_Dictionary* pDict, bool bDictNeedClone); void DeleteLastMark(); diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 0cc81f1e9b..2fbb73b6b2 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -184,7 +184,7 @@ void ReplaceAbbr(CPDF_Object* pObj) { if (!fullname.IsEmpty()) { AbbrReplacementOp op; op.is_replace_key = true; - op.key = key; + op.key = std::move(key); op.replacement = fullname; replacements.push_back(op); key = fullname; @@ -606,9 +606,8 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent_Dictionary() { return; bDirect = false; } - if (const CPDF_Dictionary* pDict = pProperty->AsDictionary()) { - m_CurContentMark.AddMark(tag, pDict, bDirect); - } + if (const CPDF_Dictionary* pDict = pProperty->AsDictionary()) + m_CurContentMark.AddMark(std::move(tag), pDict, bDirect); } void CPDF_StreamContentParser::Handle_BeginImage() { @@ -755,20 +754,23 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { if (pXObject->GetDict()) type = pXObject->GetDict()->GetStringFor("Subtype"); + if (type == "Form") { + AddForm(pXObject); + return; + } + if (type == "Image") { CPDF_ImageObject* pObj = pXObject->IsInline() ? AddImage(std::unique_ptr( ToStream(pXObject->Clone()))) : AddImage(pXObject->GetObjNum()); - m_LastImageName = name; + m_LastImageName = std::move(name); if (pObj) { m_pLastImage = pObj->GetImage(); if (m_pLastImage->IsMask()) m_pObjectHolder->AddImageMaskBoundingBox(pObj->GetRect()); } - } else if (type == "Form") { - AddForm(pXObject); } } @@ -1307,7 +1309,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { ByteString str = pObj->GetString(); if (str.IsEmpty()) continue; - strs[iSegment] = str; + strs[iSegment] = std::move(str); kernings[iSegment++] = 0; } else { float num = pObj->GetNumber(); -- cgit v1.2.3