Removed hand rolled bsearch from IsKeyword method

BUG=pdfium:786

Change-Id: I7a852566cdde301ee896c12d9d29043047c31ad4
Reviewed-on: https://pdfium-review.googlesource.com/7211
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
index 433839a..7537041 100644
--- a/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmlexer.cpp
@@ -6,6 +6,8 @@
 
 #include "xfa/fxfa/fm2js/cxfa_fmlexer.h"
 
+#include <algorithm>
+
 #include "core/fxcrt/fx_extension.h"
 #include "third_party/base/ptr_util.h"
 
@@ -472,18 +474,15 @@
 }
 
 XFA_FM_TOKEN CXFA_FMLexer::IsKeyword(const CFX_WideStringC& str) {
-  uint32_t uHash = FX_HashCode_GetW(str, true);
-  int32_t iStart = KEYWORD_START;
-  int32_t iEnd = KEYWORD_END;
-  do {
-    int32_t iMid = (iStart + iEnd) / 2;
-    XFA_FMKeyword keyword = keyWords[iMid];
-    if (uHash == keyword.m_uHash)
-      return keyword.m_type;
-    if (uHash < keyword.m_uHash)
-      iEnd = iMid - 1;
-    else
-      iStart = iMid + 1;
-  } while (iStart <= iEnd);
+  uint32_t key = FX_HashCode_GetW(str, true);
+  auto cmpFunc = [](const XFA_FMKeyword& iter, const uint32_t& val) {
+    return iter.m_uHash < val;
+  };
+
+  const XFA_FMKeyword* result = std::lower_bound(
+      std::begin(keyWords) + KEYWORD_START, std::end(keyWords), key, cmpFunc);
+  if (result <= keyWords + KEYWORD_END && result->m_uHash == key) {
+    return result->m_type;
+  }
   return TOKidentifier;
 }