From c62e8489042c5efaa3b666846b38a52da3b91481 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 20 Jun 2018 20:32:04 +0000 Subject: Avoid more .c_str() usage, part 3 Change-Id: I5dfadcb68e640235be6e3eb7c8d57ae3b8013d26 Reviewed-on: https://pdfium-review.googlesource.com/35691 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- xfa/fgas/font/cfgas_fontmgr.cpp | 13 +++++-------- xfa/fgas/font/cfgas_fontmgr.h | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'xfa/fgas') diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 59d4563c29..5ab91b3cc6 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -690,11 +690,10 @@ int32_t CFGAS_FontMgr::CalcPenalty(CFX_FontDescriptor* pInstalled, } else { nPenalty -= 30000; } - if (30000 == nPenalty && - 0 == IsPartName(pInstalled->m_wsFaceName, FontName)) { + if (nPenalty == 30000 && !IsPartName(pInstalled->m_wsFaceName, FontName)) { size_t i; for (i = 0; i < pInstalled->m_wsFamilyNames.size(); i++) { - if (IsPartName(pInstalled->m_wsFamilyNames[i], FontName) != 0) + if (IsPartName(pInstalled->m_wsFamilyNames[i], FontName)) break; } if (i == pInstalled->m_wsFamilyNames.size()) @@ -884,11 +883,9 @@ void CFGAS_FontMgr::GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB) { CSB[1] = pOS2->ulCodePageRange2; } -int32_t CFGAS_FontMgr::IsPartName(const WideString& Name1, - const WideString& Name2) { - if (Name1.Contains(Name2.c_str())) - return 1; - return 0; +bool CFGAS_FontMgr::IsPartName(const WideString& name1, + const WideString& name2) { + return name1.Contains(name2.AsStringView()); } #endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h index f082b02dd3..5a1e9babf6 100644 --- a/xfa/fgas/font/cfgas_fontmgr.h +++ b/xfa/fgas/font/cfgas_fontmgr.h @@ -160,7 +160,7 @@ class CFGAS_FontMgr : public Observable { void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); uint32_t GetFlags(FXFT_Face pFace); bool VerifyUnicode(CFX_FontDescriptor* pDesc, wchar_t wcUnicode); - int32_t IsPartName(const WideString& Name1, const WideString& Name2); + bool IsPartName(const WideString& name1, const WideString& name2); void MatchFonts(std::vector* MatchedFonts, uint16_t wCodePage, uint32_t dwFontStyles, -- cgit v1.2.3