summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-07-05 10:39:20 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-05 15:20:55 +0000
commitd7403971a25c317671e92ccc676a5f600ed223eb (patch)
tree34782850989cb61c0ad270fa91813d02cac60185 /xfa/fxfa
parentea7555ae8cae2f50dfb2322d5c19384f43212bd5 (diff)
downloadpdfium-d7403971a25c317671e92ccc676a5f600ed223eb.tar.xz
Extract comparison functions from std::lower_bound args
Cleanup of code I changed earlier last week, to match the style recommended in later reviews and make it more readable. BUG=pdfium:786 Change-Id: I2ff8b980a229718e389ad1a8063bd5059aedb66c Reviewed-on: https://pdfium-review.googlesource.com/7212 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index 8078ae9841..955b06fe93 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -520,14 +520,14 @@ bool CXFA_FMCallExpression::IsBuiltInFunc(CFX_WideTextBuf* funcName) {
if (funcName->GetLength() > g_BuiltInFuncsMaxLen)
return false;
+ auto cmpFunc = [](const wchar_t* iter, const CFX_WideString& val) -> bool {
+ return val.CompareNoCase(iter) > 0;
+ };
CFX_WideString str = funcName->MakeString();
- const wchar_t* const* pEnd = g_BuiltInFuncs + FX_ArraySize(g_BuiltInFuncs);
const wchar_t* const* pMatchResult = std::lower_bound(
- g_BuiltInFuncs, pEnd, str,
- [](const wchar_t* iter, const CFX_WideString& val) -> bool {
- return val.CompareNoCase(iter) > 0;
- });
- if (pMatchResult < pEnd && !str.CompareNoCase(*pMatchResult)) {
+ std::begin(g_BuiltInFuncs), std::end(g_BuiltInFuncs), str, cmpFunc);
+ if (pMatchResult != std::end(g_BuiltInFuncs) &&
+ !str.CompareNoCase(*pMatchResult)) {
funcName->Clear();
*funcName << *pMatchResult;
return true;
@@ -537,11 +537,12 @@ bool CXFA_FMCallExpression::IsBuiltInFunc(CFX_WideTextBuf* funcName) {
uint32_t CXFA_FMCallExpression::IsMethodWithObjParam(
const CFX_WideString& methodName) {
- const XFA_FMSOMMethod* result = std::lower_bound(
- std::begin(gs_FMSomMethods), std::end(gs_FMSomMethods), methodName,
- [](const XFA_FMSOMMethod iter, const CFX_WideString& val) {
- return val.Compare(iter.m_wsSomMethodName) > 0;
- });
+ auto cmpFunc = [](const XFA_FMSOMMethod iter, const CFX_WideString& val) {
+ return val.Compare(iter.m_wsSomMethodName) > 0;
+ };
+ const XFA_FMSOMMethod* result =
+ std::lower_bound(std::begin(gs_FMSomMethods), std::end(gs_FMSomMethods),
+ methodName, cmpFunc);
if (result != std::end(gs_FMSomMethods) &&
!methodName.Compare(result->m_wsSomMethodName)) {
return result->m_dParameters;