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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/xfa_basic_imp.h" 7 #include "xfa/fxfa/parser/xfa_basic_imp.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fgas/crt/fgas_algorithm.h"
11 #include "xfa/fgas/crt/fgas_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
12 #include "xfa/fgas/crt/fgas_system.h" 11 #include "xfa/fgas/crt/fgas_system.h"
13 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" 12 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
14 #include "xfa/fxfa/parser/xfa_basic_data.h" 13 #include "xfa/fxfa/parser/xfa_basic_data.h"
15 #include "xfa/fxfa/parser/xfa_doclayout.h" 14 #include "xfa/fxfa/parser/xfa_doclayout.h"
16 #include "xfa/fxfa/parser/xfa_document.h" 15 #include "xfa/fxfa/parser/xfa_document.h"
17 #include "xfa/fxfa/parser/xfa_localemgr.h" 16 #include "xfa/fxfa/parser/xfa_localemgr.h"
18 #include "xfa/fxfa/parser/xfa_object.h" 17 #include "xfa/fxfa/parser/xfa_object.h"
19 #include "xfa/fxfa/parser/xfa_parser.h" 18 #include "xfa/fxfa/parser/xfa_parser.h"
20 #include "xfa/fxfa/parser/xfa_script.h" 19 #include "xfa/fxfa/parser/xfa_script.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return g_XFAElementChildrenData + pElement->wStart; 207 return g_XFAElementChildrenData + pElement->wStart;
209 } 208 }
210 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) { 209 const uint8_t* XFA_GetElementAttributes(XFA_ELEMENT eElement, int32_t& iCount) {
211 if (eElement >= g_iXFAElementCount) { 210 if (eElement >= g_iXFAElementCount) {
212 return NULL; 211 return NULL;
213 } 212 }
214 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement; 213 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementAttributeIndex + eElement;
215 iCount = pElement->wCount; 214 iCount = pElement->wCount;
216 return g_XFAElementAttributeData + pElement->wStart; 215 return g_XFAElementAttributeData + pElement->wStart;
217 } 216 }
217
218 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement, 218 const XFA_ATTRIBUTEINFO* XFA_GetAttributeOfElement(XFA_ELEMENT eElement,
219 XFA_ATTRIBUTE eAttribute, 219 XFA_ATTRIBUTE eAttribute,
220 uint32_t dwPacket) { 220 uint32_t dwPacket) {
221 int32_t iCount = 0; 221 int32_t iCount = 0;
222 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount); 222 const uint8_t* pAttr = XFA_GetElementAttributes(eElement, iCount);
223 if (pAttr == NULL || iCount < 1) { 223 if (!pAttr || iCount < 1)
224 return NULL; 224 return nullptr;
225 } 225
226 CFX_DSPATemplate<uint8_t> search; 226 if (!std::binary_search(pAttr, pAttr + iCount, eAttribute))
227 int32_t index = search.Lookup(eAttribute, pAttr, iCount); 227 return nullptr;
228 if (index < 0) { 228
229 return NULL;
230 }
231 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute); 229 const XFA_ATTRIBUTEINFO* pInfo = XFA_GetAttributeByID(eAttribute);
232 ASSERT(pInfo); 230 ASSERT(pInfo);
233 if (dwPacket == XFA_XDPPACKET_UNKNOWN) 231 if (dwPacket == XFA_XDPPACKET_UNKNOWN)
234 return pInfo; 232 return pInfo;
235 return (dwPacket & pInfo->dwPackets) ? pInfo : NULL; 233 return (dwPacket & pInfo->dwPackets) ? pInfo : nullptr;
236 } 234 }
237 235
238 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement, 236 const XFA_PROPERTY* XFA_GetElementProperties(XFA_ELEMENT eElement,
239 int32_t& iCount) { 237 int32_t& iCount) {
240 if (eElement >= g_iXFAElementCount) { 238 if (eElement >= g_iXFAElementCount) {
241 return NULL; 239 return NULL;
242 } 240 }
243 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement; 241 const XFA_ELEMENTHIERARCHY* pElement = g_XFAElementPropertyIndex + eElement;
244 iCount = pElement->wCount; 242 iCount = pElement->wCount;
245 return g_XFAElementPropertyData + pElement->wStart; 243 return g_XFAElementPropertyData + pElement->wStart;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 m_iPosition += iMaxLength; 565 m_iPosition += iMaxLength;
568 bEOS = IsEOF(); 566 bEOS = IsEOF();
569 return iMaxLength; 567 return iMaxLength;
570 } 568 }
571 uint16_t CXFA_WideTextRead::GetCodePage() const { 569 uint16_t CXFA_WideTextRead::GetCodePage() const {
572 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE; 570 return (sizeof(FX_WCHAR) == 2) ? FX_CODEPAGE_UTF16LE : FX_CODEPAGE_UTF32LE;
573 } 571 }
574 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) { 572 uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
575 return GetCodePage(); 573 return GetCodePage();
576 } 574 }
OLDNEW
« 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