diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-04-18 16:36:11 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-18 23:53:20 +0000 |
commit | 5af27b63bf94e7f60212f6759c8342ce02da5ad2 (patch) | |
tree | ad5c42c2632b521b98cc7058cd00d345fb2a5756 /xfa/fxfa/parser/xfa_utils.cpp | |
parent | 3420ba852babe24c7b03fede1b3b7c474c148c0d (diff) | |
download | pdfium-5af27b63bf94e7f60212f6759c8342ce02da5ad2.tar.xz |
Remove hand-written bsearch from XFA_GetAttributeEnumByName()
Change-Id: Ic4bf34dfbdd06971d8935d031bdb7996c78d262f
Reviewed-on: https://pdfium-review.googlesource.com/4315
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/xfa_utils.cpp')
-rw-r--r-- | xfa/fxfa/parser/xfa_utils.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp index 75d017b070..2ffba9b2e6 100644 --- a/xfa/fxfa/parser/xfa_utils.cpp +++ b/xfa/fxfa/parser/xfa_utils.cpp @@ -455,19 +455,12 @@ const XFA_ATTRIBUTEENUMINFO* XFA_GetAttributeEnumByName( if (wsName.IsEmpty()) return nullptr; - uint32_t uHash = FX_HashCode_GetW(wsName, false); - int32_t iStart = 0; - int32_t iEnd = g_iXFAEnumCount - 1; - do { - int32_t iMid = (iStart + iEnd) / 2; - const XFA_ATTRIBUTEENUMINFO* pInfo = g_XFAEnumData + iMid; - if (uHash == pInfo->uHash) - return pInfo; - if (uHash < pInfo->uHash) - iEnd = iMid - 1; - else - iStart = iMid + 1; - } while (iStart <= iEnd); + auto* it = std::lower_bound(g_XFAEnumData, g_XFAEnumData + g_iXFAEnumCount, + FX_HashCode_GetW(wsName, false), + [](const XFA_ATTRIBUTEENUMINFO& arg, + uint32_t hash) { return arg.uHash < hash; }); + if (it != g_XFAEnumData + g_iXFAEnumCount && wsName == it->pName) + return it; return nullptr; } |