Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1916)

Unified Diff: xfa/src/fgas/src/localization/fx_locale.cpp

Issue 1732223002: Use std::lower_bound() in a couple places. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fgas/src/localization/fx_locale.cpp
diff --git a/xfa/src/fgas/src/localization/fx_locale.cpp b/xfa/src/fgas/src/localization/fx_locale.cpp
index 46eeae0c4faf4689a4d9e7e1e07b7edf0b8ee511..ca12dbb69e4e19edad2d0efa50ad4a19d5cabad9 100644
--- a/xfa/src/fgas/src/localization/fx_locale.cpp
+++ b/xfa/src/fgas/src/localization/fx_locale.cpp
@@ -55,8 +55,6 @@ static const FX_LOCALETIMEZONEINFO g_FXLocaleTimeZoneData[] = {
{FXBSTR_ID(0, 'M', 'D', 'T'), -6, 0}, {FXBSTR_ID(0, 'M', 'S', 'T'), -7, 0},
{FXBSTR_ID(0, 'P', 'D', 'T'), -7, 0}, {FXBSTR_ID(0, 'P', 'S', 'T'), -8, 0},
};
-static const int32_t g_iFXLocaleTimeZoneCount =
- sizeof(g_FXLocaleTimeZoneData) / sizeof(FX_LOCALETIMEZONEINFO);
static const CFX_WideStringC gs_wsTextSymbols = FX_WSTRC(L"AXO09");
static const CFX_WideStringC gs_wsTimeSymbols = FX_WSTRC(L"hHkKMSFAzZ");
@@ -2771,22 +2769,13 @@ static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime,
}
FX_ResolveZone(hour, minute, tzDiff, pLocale);
} else {
- const FX_LOCALETIMEZONEINFO* pTimeZoneInfo = NULL;
- int32_t iStart = 0;
- int32_t iEnd = g_iFXLocaleTimeZoneCount - 1;
- do {
- int32_t iMid = (iStart + iEnd) / 2;
- const FX_LOCALETIMEZONEINFO* pInfo = g_FXLocaleTimeZoneData + iMid;
- if (dwHash == pInfo->uHash) {
- pTimeZoneInfo = pInfo;
- break;
- } else if (dwHash < pInfo->uHash) {
- iEnd = iMid - 1;
- } else {
- iStart = iMid + 1;
- }
- } while (iStart <= iEnd);
- if (pTimeZoneInfo) {
+ const FX_LOCALETIMEZONEINFO* pEnd =
+ g_FXLocaleTimeZoneData + FX_ArraySize(g_FXLocaleTimeZoneData);
+ const FX_LOCALETIMEZONEINFO* pTimeZoneInfo =
+ std::lower_bound(g_FXLocaleTimeZoneData, pEnd, dwHash,
+ [](const FX_LOCALETIMEZONEINFO& info,
+ FX_DWORD hash) { return info.uHash < hash; });
+ if (pTimeZoneInfo < pEnd && dwHash == pTimeZoneInfo->uHash) {
hour += pTimeZoneInfo->iHour;
minute += pTimeZoneInfo->iHour > 0 ? pTimeZoneInfo->iMinute
: -pTimeZoneInfo->iMinute;
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | xfa/src/fxfa/src/fm2js/xfa_simpleexpression.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698