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

Unified Diff: xfa/fxfa/parser/xfa_basic_imp.cpp

Issue 2007443003: Replace CFX_DSPATemplate with std::binary_search. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxfa/parser/xfa_basic_imp.cpp
diff --git a/xfa/fxfa/parser/xfa_basic_imp.cpp b/xfa/fxfa/parser/xfa_basic_imp.cpp
index 759d53043993c68afeb72e3797395178eac18917..8f53b574672b379fe50ed0a2155aa4839d8b90ba 100644
--- a/xfa/fxfa/parser/xfa_basic_imp.cpp
+++ b/xfa/fxfa/parser/xfa_basic_imp.cpp
@@ -7,7 +7,6 @@
#include "xfa/fxfa/parser/xfa_basic_imp.h"
#include "core/fxcrt/include/fx_ext.h"
-#include "xfa/fgas/crt/fgas_algorithm.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fgas/crt/fgas_system.h"
#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
@@ -215,24 +214,23 @@ const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) {
iCount = pElement->wCount;
return g_XFAElementAttributeData + pElement->wStart;
}
+
const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement,
XFA_ATTRIBUTE eAttribute,
uint32_t dwPacket) {
int32_t iCount = 0;
const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount);
- if (pAttr == NULL || iCount < 1) {
- return NULL;
- }
- CFX_DSPATemplate<uint8_t> search;
- int32_t index = search.Lookup(eAttribute, pAttr, iCount);
- if (index < 0) {
- return NULL;
- }
+ if (!pAttr || iCount < 1)
+ return nullptr;
+
+ if (!std::binary_search(pAttr, pAttr + iCount, eAttribute))
+ return nullptr;
+
const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
ASSERT(pInfo);
if (dwPacket == XFA_XDPPACKET_UNKNOWN)
return pInfo;
- return (dwPacket & pInfo->dwPackets) ? pInfo : NULL;
+ return (dwPacket & pInfo->dwPackets) ? pInfo : nullptr;
}
const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement,
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698