summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-21 15:02:24 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-21 15:02:24 +0000
commit9c292fef316739f43730f11b9a2b6d3e4b725b54 (patch)
treee286b6c7a36c50eba235c7b69b30b95fc36cb906
parentbcd66f54de1291ddf8b7b7caca3e7360e14fcc8d (diff)
downloadpdfium-9c292fef316739f43730f11b9a2b6d3e4b725b54.tar.xz
Avoid const-refs to implicitly constructed strings.
Because the invisible temporary goes out of scope at the next semicolon. Also avoid returning const string references since the cost is low to properly keep the string alive. Change-Id: Id283e4fd99f79a02d79d739a533a4ce05e831e2a Reviewed-on: https://pdfium-review.googlesource.com/35710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fpdfapi/font/cpdf_font.h2
-rw-r--r--core/fpdfapi/parser/cpdf_object_walker.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_object_walker.h4
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h2
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp5
-rw-r--r--core/fpdfdoc/cpdf_filespec.cpp4
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp4
-rw-r--r--core/fpdfdoc/cpdf_structelement.h4
-rw-r--r--fxjs/cjs_eventhandler.cpp4
-rw-r--r--fxjs/cjs_eventhandler.h4
10 files changed, 15 insertions, 20 deletions
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index a137879891..4b099ae0d0 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -63,7 +63,7 @@ class CPDF_Font {
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const;
virtual bool HasFontWidths() const;
- const ByteString& GetBaseFont() const { return m_BaseFont; }
+ ByteString GetBaseFont() const { return m_BaseFont; }
CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); }
bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; }
const CPDF_Dictionary* GetFontDict() const { return m_pFontDict; }
diff --git a/core/fpdfapi/parser/cpdf_object_walker.cpp b/core/fpdfapi/parser/cpdf_object_walker.cpp
index cb59a05d06..3aaa25e9f7 100644
--- a/core/fpdfapi/parser/cpdf_object_walker.cpp
+++ b/core/fpdfapi/parser/cpdf_object_walker.cpp
@@ -57,7 +57,7 @@ class DictionaryIterator : public CPDF_ObjectWalker::SubobjectIterator {
dict_iterator_ = object()->GetDict()->begin();
}
- const ByteString& dict_key() const { return dict_key_; }
+ ByteString dict_key() const { return dict_key_; }
private:
CPDF_Dictionary::const_iterator dict_iterator_;
diff --git a/core/fpdfapi/parser/cpdf_object_walker.h b/core/fpdfapi/parser/cpdf_object_walker.h
index 8cad3c32f3..d677712c9b 100644
--- a/core/fpdfapi/parser/cpdf_object_walker.h
+++ b/core/fpdfapi/parser/cpdf_object_walker.h
@@ -41,7 +41,7 @@ class CPDF_ObjectWalker {
size_t current_depth() const { return current_depth_; }
const CPDF_Object* GetParent() const { return parent_object_; }
- const ByteString& dictionary_key() const { return dict_key_; }
+ ByteString dictionary_key() const { return dict_key_; }
private:
static std::unique_ptr<SubobjectIterator> MakeIterator(
@@ -49,10 +49,8 @@ class CPDF_ObjectWalker {
const CPDF_Object* next_object_;
const CPDF_Object* parent_object_;
-
ByteString dict_key_;
size_t current_depth_;
-
std::stack<std::unique_ptr<SubobjectIterator>> stack_;
};
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index cd836340fd..00bd353fcb 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -36,7 +36,7 @@ class CPDF_StreamAcc : public Retainable {
pdfium::span<uint8_t> GetSpan() const {
return pdfium::make_span(GetData(), GetSize());
}
- const ByteString& GetImageDecoder() const { return m_ImageDecoder; }
+ ByteString GetImageDecoder() const { return m_ImageDecoder; }
const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; }
std::unique_ptr<uint8_t, FxFreeDeleter> DetachData();
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index 98a2dda999..72dec67438 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -288,8 +288,7 @@ CPDF_DIBSource::LoadState CPDF_DIBSource::ContinueLoadDIBSource(
if (m_Status == LoadState::kFail)
return LoadState::kFail;
- const ByteString& decoder = m_pStreamAcc->GetImageDecoder();
- if (decoder == "JPXDecode")
+ if (m_pStreamAcc->GetImageDecoder() == "JPXDecode")
return LoadState::kFail;
FXCODEC_STATUS iDecodeStatus;
@@ -448,7 +447,7 @@ bool CPDF_DIBSource::GetDecodeAndMaskArray(bool* bDefaultDecode,
}
CPDF_DIBSource::LoadState CPDF_DIBSource::CreateDecoder() {
- const ByteString& decoder = m_pStreamAcc->GetImageDecoder();
+ ByteString decoder = m_pStreamAcc->GetImageDecoder();
if (decoder.IsEmpty())
return LoadState::kSuccess;
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index 88abea30d5..95254b7bb8 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -138,7 +138,7 @@ const CPDF_Stream* CPDF_FileSpec::GetFileStream() const {
size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : FX_ArraySize(kKeys);
for (size_t i = 0; i < end; ++i) {
- const ByteString& key = kKeys[i];
+ ByteString key = kKeys[i];
if (!pDict->GetUnicodeTextFor(key).IsEmpty()) {
const CPDF_Stream* pStream = pFiles->GetStreamFor(key);
if (pStream)
@@ -160,7 +160,7 @@ CPDF_Stream* CPDF_FileSpec::GetFileStream() {
size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : FX_ArraySize(kKeys);
for (size_t i = 0; i < end; ++i) {
- const ByteString& key = kKeys[i];
+ ByteString key = kKeys[i];
if (!pDict->GetUnicodeTextFor(key).IsEmpty()) {
CPDF_Stream* pStream = pFiles->GetStreamFor(key);
if (pStream)
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index b18310cfde..d7cee35704 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -379,9 +379,7 @@ class CFieldTree {
}
CPDF_FormField* GetField() const { return m_pField.get(); }
-
- const WideString& GetShortName() const { return m_ShortName; }
-
+ WideString GetShortName() const { return m_ShortName; }
int GetLevel() const { return m_level; }
private:
diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h
index 4e590cb879..79e8dd92c8 100644
--- a/core/fpdfdoc/cpdf_structelement.h
+++ b/core/fpdfdoc/cpdf_structelement.h
@@ -39,8 +39,8 @@ class CPDF_StructElement : public Retainable {
template <typename T, typename... Args>
friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
- const ByteString& GetType() const { return m_Type; }
- const ByteString& GetTitle() const { return m_Title; }
+ ByteString GetType() const { return m_Type; }
+ ByteString GetTitle() const { return m_Title; }
const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
size_t CountKids() const;
diff --git a/fxjs/cjs_eventhandler.cpp b/fxjs/cjs_eventhandler.cpp
index 0fd330fd13..43605d985b 100644
--- a/fxjs/cjs_eventhandler.cpp
+++ b/fxjs/cjs_eventhandler.cpp
@@ -396,7 +396,7 @@ WideString& CJS_EventHandler::Change() {
return m_WideStrChangeDu;
}
-const WideString& CJS_EventHandler::ChangeEx() {
+WideString CJS_EventHandler::ChangeEx() const {
return m_WideStrChangeEx;
}
@@ -628,6 +628,6 @@ bool CJS_EventHandler::WillCommit() const {
return m_bWillCommit;
}
-const WideString& CJS_EventHandler::TargetName() const {
+WideString CJS_EventHandler::TargetName() const {
return m_strTargetName;
}
diff --git a/fxjs/cjs_eventhandler.h b/fxjs/cjs_eventhandler.h
index aa02895924..7c33ed739e 100644
--- a/fxjs/cjs_eventhandler.h
+++ b/fxjs/cjs_eventhandler.h
@@ -144,7 +144,7 @@ class CJS_EventHandler {
bool IsValid() const;
WideString& Change();
- const WideString& ChangeEx();
+ WideString ChangeEx() const;
int CommitKey() const;
bool FieldFull() const;
bool KeyDown() const;
@@ -161,7 +161,7 @@ class CJS_EventHandler {
CJS_Field* Target_Field();
WideString& Value();
bool WillCommit() const;
- const WideString& TargetName() const;
+ WideString TargetName() const;
JS_EVENT_T EventType() const { return m_eEventType; }