From 8b36e5cc3d5f5f579c6b060e2c40b896a4b02bc0 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 8 Apr 2016 09:00:35 -0700 Subject: 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 --- core/fpdfdoc/doc_basic.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'core/fpdfdoc/doc_basic.cpp') 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; } -- cgit v1.2.3