From 3c3e271ea9fd19dd535a74b5546b27e3e82dcb81 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 17 Apr 2017 15:38:19 -0700 Subject: Use Byte/WideString iterators Change-Id: I85c8423c177fd7ecd5da90ef89419efc0f9cf44b Reviewed-on: https://pdfium-review.googlesource.com/4262 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxcrt/fx_bidi.cpp | 4 ++-- core/fxcrt/fx_extension.cpp | 16 ++++++++-------- core/fxge/ge/cfx_fontmapper.cpp | 12 ++++-------- 3 files changed, 14 insertions(+), 18 deletions(-) (limited to 'core') diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp index 5ad6439e07..49333f6a76 100644 --- a/core/fxcrt/fx_bidi.cpp +++ b/core/fxcrt/fx_bidi.cpp @@ -52,8 +52,8 @@ CFX_BidiString::CFX_BidiString(const CFX_WideString& str) : m_Str(str), m_pBidiChar(new CFX_BidiChar), m_eOverallDirection(CFX_BidiChar::LEFT) { - for (int i = 0; i < m_Str.GetLength(); ++i) { - if (m_pBidiChar->AppendChar(m_Str.GetAt(i))) + for (const auto& c : m_Str) { + if (m_pBidiChar->AppendChar(c)) m_Order.push_back(m_pBidiChar->GetSegmentInfo()); } if (m_pBidiChar->EndChar()) diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index acdce048e0..f3e72fd6df 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -509,11 +509,11 @@ int32_t FXSYS_strnicmp(const char* s1, const char* s2, size_t count) { uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) { uint32_t dwHashCode = 0; if (bIgnoreCase) { - for (FX_STRSIZE i = 0; i < str.GetLength(); ++i) - dwHashCode = 31 * dwHashCode + FXSYS_tolower(str.CharAt(i)); + for (const auto& c : str) + dwHashCode = 31 * dwHashCode + FXSYS_tolower(c); } else { - for (FX_STRSIZE i = 0; i < str.GetLength(); ++i) - dwHashCode = 31 * dwHashCode + str.CharAt(i); + for (const auto& c : str) + dwHashCode = 31 * dwHashCode + c; } return dwHashCode; } @@ -521,11 +521,11 @@ uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase) { uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase) { uint32_t dwHashCode = 0; if (bIgnoreCase) { - for (FX_STRSIZE i = 0; i < str.GetLength(); ++i) - dwHashCode = 1313 * dwHashCode + FXSYS_tolower(str.CharAt(i)); + for (const auto& c : str) + dwHashCode = 1313 * dwHashCode + FXSYS_tolower(c); } else { - for (FX_STRSIZE i = 0; i < str.GetLength(); ++i) - dwHashCode = 1313 * dwHashCode + str.CharAt(i); + for (const auto& c : str) + dwHashCode = 1313 * dwHashCode + c; } return dwHashCode; } diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp index 0cff344599..ff80685d96 100644 --- a/core/fxge/ge/cfx_fontmapper.cpp +++ b/core/fxge/ge/cfx_fontmapper.cpp @@ -6,6 +6,7 @@ #include "core/fxge/cfx_fontmapper.h" +#include #include #include #include @@ -326,14 +327,9 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) { if (name == m_LastFamily) return; - const uint8_t* ptr = name.raw_str(); - bool bLocalized = false; - for (int i = 0; i < name.GetLength(); i++) { - if (ptr[i] > 0x80) { - bLocalized = true; - break; - } - } + bool bLocalized = std::any_of(name.begin(), name.end(), [](const char& c) { + return static_cast(c) > 0x80; + }); if (bLocalized) { void* hFont = m_pFontInfo->GetFont(name.c_str()); -- cgit v1.2.3