Re-write the loop in CXFA_FWLTheme::LoadCalendarFont()
I found it annoying to look at while working on a previous CL,
though I probably was the person that last touched it.
-- Rename array to kFWLThemeCalFonts and make constexpr
Change-Id: I26c828050af062a2f3a01927442f9b6fb87c3b1c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73390
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp
index 5929cce..d286213 100644
--- a/xfa/fxfa/cxfa_fwltheme.cpp
+++ b/xfa/fxfa/cxfa_fwltheme.cpp
@@ -34,7 +34,7 @@
namespace {
-const wchar_t* const g_FWLTheme_CalFonts[] = {
+constexpr const wchar_t* kFWLThemeCalFonts[] = {
L"Arial",
L"Courier New",
L"DejaVu Sans",
@@ -65,15 +65,17 @@
}
bool CXFA_FWLTheme::LoadCalendarFont(CXFA_FFDoc* doc) {
- for (size_t i = 0; !m_pCalendarFont && i < pdfium::size(g_FWLTheme_CalFonts);
- ++i) {
- m_pCalendarFont =
- m_pApp->GetXFAFontMgr()->GetFont(doc, g_FWLTheme_CalFonts[i], 0);
+ if (m_pCalendarFont)
+ return true;
+
+ for (const wchar_t* font : kFWLThemeCalFonts) {
+ m_pCalendarFont = m_pApp->GetXFAFontMgr()->GetFont(doc, font, 0);
+ if (m_pCalendarFont)
+ return true;
}
- if (!m_pCalendarFont) {
- m_pCalendarFont = CFGAS_GEModule::Get()->GetFontMgr()->GetFontByCodePage(
- FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr);
- }
+
+ m_pCalendarFont = CFGAS_GEModule::Get()->GetFontMgr()->GetFontByCodePage(
+ FX_CODEPAGE_MSWin_WesternEuropean, 0, nullptr);
return !!m_pCalendarFont;
}