summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-01-31 20:16:04 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-31 20:16:04 +0000
commita975a83691dbfdf34754c7705dcc715bc5c73820 (patch)
treeb55462e46ef8256153d2f8ea34b8b75e2c102a04 /xfa/fxfa/parser
parent405f17ae3f297d28917370d013d95adc31e7c4a1 (diff)
downloadpdfium-a975a83691dbfdf34754c7705dcc715bc5c73820.tar.xz
Remove handrolled bsearch from XFA_GetScriptAttributeByName
BUG=pdfium:798 Change-Id: Ie680eff06fdee49d843e0cb847ee9c919975cfb5 Reviewed-on: https://pdfium-review.googlesource.com/24779 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp22
-rw-r--r--xfa/fxfa/parser/xfa_utils.h2
2 files changed, 11 insertions, 13 deletions
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index 785119b62e..f0d2afdbcc 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -579,30 +579,28 @@ int32_t XFA_MapRotation(int32_t nRotation) {
const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
XFA_Element eElement,
- const WideStringView& wsAttributeName) {
+ WideStringView wsAttributeName) {
if (wsAttributeName.IsEmpty())
return nullptr;
int32_t iElementIndex = static_cast<int32_t>(eElement);
while (iElementIndex != -1) {
const XFA_SCRIPTHIERARCHY* scriptIndex = g_XFAScriptIndex + iElementIndex;
- int32_t icount = scriptIndex->wAttributeCount;
- if (icount == 0) {
+ size_t iCount = scriptIndex->wAttributeCount;
+ if (iCount == 0) {
iElementIndex = scriptIndex->wParentIndex;
continue;
}
+
uint32_t uHash = FX_HashCode_GetW(wsAttributeName, false);
- int32_t iStart = scriptIndex->wAttributeStart, iEnd = iStart + icount - 1;
- do {
- int32_t iMid = (iStart + iEnd) / 2;
- const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iMid;
+ size_t iStart = scriptIndex->wAttributeStart;
+ size_t iEnd = iStart + iCount;
+ for (size_t iter = iStart; iter < iEnd; ++iter) {
+ const XFA_SCRIPTATTRIBUTEINFO* pInfo = g_SomAttributeData + iter;
if (uHash == pInfo->uHash)
return pInfo;
- if (uHash < pInfo->uHash)
- iEnd = iMid - 1;
- else
- iStart = iMid + 1;
- } while (iStart <= iEnd);
+ }
+
iElementIndex = scriptIndex->wParentIndex;
}
return nullptr;
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index 2dfdb1a381..3b59ac8b3a 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -37,6 +37,6 @@ void XFA_DataExporter_RegenerateFormFile(
const XFA_SCRIPTATTRIBUTEINFO* XFA_GetScriptAttributeByName(
XFA_Element eElement,
- const WideStringView& wsAttributeName);
+ WideStringView wsAttributeName);
#endif // XFA_FXFA_PARSER_XFA_UTILS_H_