summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-08 09:00:35 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-08 09:00:35 -0700
commit8b36e5cc3d5f5f579c6b060e2c40b896a4b02bc0 (patch)
treef84a20d330d92b791d0322f424cb155816d77d1b /core/fpdfdoc
parent8da140e8747920057a2f2bbcf5c78e40bb198733 (diff)
downloadpdfium-8b36e5cc3d5f5f579c6b060e2c40b896a4b02bc0.tar.xz
Make CFX_WideString::FromLocal() take a CFX_ByteStringC arg
It doesn't persist the string beyond the duration of the call, hence it should take the *StringC variant. Doing so avoids some allocs by changing to the *StringC ctor in a few places, at the cost of some explicit .ToByteStringC() calls (which are cheap). Review URL: https://codereview.chromium.org/1862953004
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/doc_action.cpp3
-rw-r--r--core/fpdfdoc/doc_basic.cpp14
-rw-r--r--core/fpdfdoc/doc_form.cpp5
3 files changed, 14 insertions, 8 deletions
diff --git a/core/fpdfdoc/doc_action.cpp b/core/fpdfdoc/doc_action.cpp
index c3ab552606..075849482c 100644
--- a/core/fpdfdoc/doc_action.cpp
+++ b/core/fpdfdoc/doc_action.cpp
@@ -73,7 +73,8 @@ CFX_WideString CPDF_Action::GetFilePath() const {
if (type == "Launch") {
CPDF_Dictionary* pWinDict = m_pDict->GetDictBy("Win");
if (pWinDict) {
- return CFX_WideString::FromLocal(pWinDict->GetStringBy("F"));
+ return CFX_WideString::FromLocal(
+ pWinDict->GetStringBy("F").AsByteStringC());
}
}
return path;
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index 9318387f7f..308bf04287 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -315,23 +315,27 @@ bool CPDF_FileSpec::GetFileName(CFX_WideString* csFileName) const {
if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
*csFileName = pDict->GetUnicodeTextBy("UF");
if (csFileName->IsEmpty()) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("F"));
+ *csFileName = CFX_WideString::FromLocal(pDict->GetConstStringBy("F"));
}
if (pDict->GetStringBy("FS") == "URL")
return true;
if (csFileName->IsEmpty()) {
if (pDict->KeyExist("DOS")) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("DOS"));
+ *csFileName = CFX_WideString::FromLocal(
+ pDict->GetStringBy("DOS").AsByteStringC());
} else if (pDict->KeyExist("Mac")) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Mac"));
+ *csFileName = CFX_WideString::FromLocal(
+ pDict->GetStringBy("Mac").AsByteStringC());
} else if (pDict->KeyExist("Unix")) {
- *csFileName = CFX_WideString::FromLocal(pDict->GetStringBy("Unix"));
+ *csFileName = CFX_WideString::FromLocal(
+ pDict->GetStringBy("Unix").AsByteStringC());
} else {
return false;
}
}
} else if (m_pObj->IsString()) {
- *csFileName = CFX_WideString::FromLocal(m_pObj->GetString());
+ *csFileName =
+ CFX_WideString::FromLocal(m_pObj->GetString().AsByteStringC());
} else {
return false;
}
diff --git a/core/fpdfdoc/doc_form.cpp b/core/fpdfdoc/doc_form.cpp
index 80c09714a2..384bcaa435 100644
--- a/core/fpdfdoc/doc_form.cpp
+++ b/core/fpdfdoc/doc_form.cpp
@@ -35,12 +35,13 @@ CFX_WideString FPDFDOC_FDF_GetFieldValue(const CPDF_Dictionary& pFieldDict,
const CFX_ByteString csBValue = pFieldDict.GetStringBy("V");
for (const auto& encoding : g_fieldEncoding) {
if (bsEncoding == encoding.m_name)
- return CFX_WideString::FromCodePage(csBValue, encoding.m_codePage);
+ return CFX_WideString::FromCodePage(csBValue.AsByteStringC(),
+ encoding.m_codePage);
}
CFX_ByteString csTemp = csBValue.Left(2);
if (csTemp == "\xFF\xFE" || csTemp == "\xFE\xFF")
return PDF_DecodeText(csBValue);
- return CFX_WideString::FromLocal(csBValue);
+ return CFX_WideString::FromLocal(csBValue.AsByteStringC());
}
} // namespace