From 89fa5dfee5107736597682f174fdc95d0baec830 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 11 Jan 2018 14:15:03 +0000 Subject: Use range-based for-loops in a few more places. Change-Id: Id403abaf3d142dc30a661bc64ff48dbd5b10948e Reviewed-on: https://pdfium-review.googlesource.com/22736 Commit-Queue: dsinclair Reviewed-by: dsinclair --- core/fxge/apple/fx_mac_imp.cpp | 6 +++--- core/fxge/cfx_unicodeencodingex.cpp | 5 ++--- core/fxge/fx_ge_linux.cpp | 12 ++++++------ fpdfsdk/pwl/cpwl_font_map.cpp | 4 ++-- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index edd36bf2bc..3f75984f47 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -65,9 +65,9 @@ void* CFX_MacFontInfo::MapFont(int weight, int pitch_family, const char* cstr_face) { ByteString face = cstr_face; - for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { - if (face == ByteStringView(g_Base14Substs[i].m_pName)) { - face = g_Base14Substs[i].m_pSubstName; + for (const auto& sub : g_Base14Substs) { + if (face == ByteStringView(sub.m_pName)) { + face = sub.m_pSubstName; return GetFont(face.c_str()); } } diff --git a/core/fxge/cfx_unicodeencodingex.cpp b/core/fxge/cfx_unicodeencodingex.cpp index 3f28d4295e..a8db745612 100644 --- a/core/fxge/cfx_unicodeencodingex.cpp +++ b/core/fxge/cfx_unicodeencodingex.cpp @@ -93,9 +93,8 @@ std::unique_ptr FX_CreateFontEncodingEx( if (nEncodingID != FXFM_ENCODING_NONE) return FXFM_CreateFontEncoding(pFont, nEncodingID); - for (size_t i = 0; i < FX_ArraySize(g_EncodingID); ++i) { - std::unique_ptr pFontEncoding = - FXFM_CreateFontEncoding(pFont, g_EncodingID[i]); + for (uint32_t id : g_EncodingID) { + auto pFontEncoding = FXFM_CreateFontEncoding(pFont, id); if (pFontEncoding) return pFontEncoding; } diff --git a/core/fxge/fx_ge_linux.cpp b/core/fxge/fx_ge_linux.cpp index 22a3c4cd1b..65c9e56ff6 100644 --- a/core/fxge/fx_ge_linux.cpp +++ b/core/fxge/fx_ge_linux.cpp @@ -100,24 +100,24 @@ void* CFX_LinuxFontInfo::MapFont(int weight, break; } case FX_CHARSET_ChineseSimplified: { - for (size_t i = 0; i < FX_ArraySize(g_LinuxGbFontList); ++i) { - auto it = m_FontList.find(g_LinuxGbFontList[i]); + for (const char* name : g_LinuxGbFontList) { + auto it = m_FontList.find(name); if (it != m_FontList.end()) return it->second.get(); } break; } case FX_CHARSET_ChineseTraditional: { - for (size_t i = 0; i < FX_ArraySize(g_LinuxB5FontList); ++i) { - auto it = m_FontList.find(g_LinuxB5FontList[i]); + for (const char* name : g_LinuxB5FontList) { + auto it = m_FontList.find(name); if (it != m_FontList.end()) return it->second.get(); } break; } case FX_CHARSET_Hangul: { - for (size_t i = 0; i < FX_ArraySize(g_LinuxHGFontList); ++i) { - auto it = m_FontList.find(g_LinuxHGFontList[i]); + for (const char* name : g_LinuxHGFontList) { + auto it = m_FontList.find(name); if (it != m_FontList.end()) return it->second.get(); } diff --git a/fpdfsdk/pwl/cpwl_font_map.cpp b/fpdfsdk/pwl/cpwl_font_map.cpp index 4a2ac4bcb8..5e5556ebb0 100644 --- a/fpdfsdk/pwl/cpwl_font_map.cpp +++ b/fpdfsdk/pwl/cpwl_font_map.cpp @@ -149,8 +149,8 @@ void CPWL_FontMap::Initialize() { } bool CPWL_FontMap::IsStandardFont(const ByteString& sFontName) { - for (size_t i = 0; i < FX_ArraySize(g_sDEStandardFontName); ++i) { - if (sFontName == g_sDEStandardFontName[i]) + for (const char* name : g_sDEStandardFontName) { + if (sFontName == name) return true; } -- cgit v1.2.3