From e47e0c96009b8633294eebbb9eb0e84caf525c57 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 26 Apr 2017 10:55:54 -0700 Subject: Avoid unordered_set and maps for the time being. See discussion at https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/rdxOHKzQmRY Change-Id: I1803ae97c39b592001835814e2f6674b2c7cb3ea Reviewed-on: https://pdfium-review.googlesource.com/4531 Reviewed-by: dsinclair Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/page/cpdf_streamcontentparser.h | 5 ++--- core/fpdfdoc/cpdf_occontext.h | 4 ++-- fpdfsdk/javascript/app.h | 4 ++-- samples/image_diff.cc | 7 ++----- xfa/fde/css/cfde_cssstylesheet.h | 4 ++-- xfa/fwl/cfwl_notedriver.h | 5 ++--- xfa/fxfa/parser/cxfa_document.cpp | 2 +- xfa/fxfa/parser/cxfa_document.h | 4 ++-- xfa/fxfa/parser/cxfa_node.cpp | 19 +++++++++---------- 9 files changed, 24 insertions(+), 30 deletions(-) diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index 4440aabb43..50eb0eb63a 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -7,8 +7,8 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ #define CORE_FPDFAPI_PAGE_CPDF_STREAMCONTENTPARSER_H_ +#include #include -#include #include #include "core/fpdfapi/page/cpdf_contentmark.h" @@ -73,8 +73,7 @@ class CPDF_StreamContentParser { static const int kParamBufSize = 16; - using OpCodes = - std::unordered_map; + using OpCodes = std::map; static OpCodes InitializeOpCodes(); void AddNameParam(const CFX_ByteStringC& str); diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h index ecdcfae31b..753aa5c176 100644 --- a/core/fpdfdoc/cpdf_occontext.h +++ b/core/fpdfdoc/cpdf_occontext.h @@ -7,7 +7,7 @@ #ifndef CORE_FPDFDOC_CPDF_OCCONTEXT_H_ #define CORE_FPDFDOC_CPDF_OCCONTEXT_H_ -#include +#include #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" @@ -40,7 +40,7 @@ class CPDF_OCContext : public CFX_Retainable { CPDF_Document* const m_pDocument; const UsageType m_eUsageType; - std::unordered_map m_OCGStates; + std::map m_OCGStates; }; #endif // CORE_FPDFDOC_CPDF_OCCONTEXT_H_ diff --git a/fpdfsdk/javascript/app.h b/fpdfsdk/javascript/app.h index 9e11b82419..0a2cfdb58e 100644 --- a/fpdfsdk/javascript/app.h +++ b/fpdfsdk/javascript/app.h @@ -8,7 +8,7 @@ #define FPDFSDK_JAVASCRIPT_APP_H_ #include -#include +#include #include #include "fpdfsdk/javascript/JS_Define.h" @@ -172,7 +172,7 @@ class app : public CJS_EmbedObj { bool m_bCalculate; bool m_bRuntimeHighLight; - std::unordered_set> m_Timers; + std::set> m_Timers; }; class CJS_App : public CJS_Object { diff --git a/samples/image_diff.cc b/samples/image_diff.cc index 3aa626be65..70c74c951c 100644 --- a/samples/image_diff.cc +++ b/samples/image_diff.cc @@ -166,9 +166,6 @@ float PercentageDifferent(const Image& baseline, const Image& actual) { return CalculateDifferencePercentage(actual, pixels_different); } -// FIXME: Replace with unordered_map when available. -typedef std::map RgbaToCountMap; - float HistogramPercentageDifferent(const Image& baseline, const Image& actual) { // TODO(johnme): Consider using a joint histogram instead, as described in // "Comparing Images Using Joint Histograms" by Pass & Zabih @@ -178,7 +175,7 @@ float HistogramPercentageDifferent(const Image& baseline, const Image& actual) { int h = std::min(baseline.h(), actual.h()); // Count occurences of each RGBA pixel value of baseline in the overlap. - RgbaToCountMap baseline_histogram; + std::map baseline_histogram; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { // hash_map operator[] inserts a 0 (default constructor) if key not found. @@ -191,7 +188,7 @@ float HistogramPercentageDifferent(const Image& baseline, const Image& actual) { for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { uint32_t actual_rgba = actual.pixel_at(x, y); - RgbaToCountMap::iterator it = baseline_histogram.find(actual_rgba); + auto it = baseline_histogram.find(actual_rgba); if (it != baseline_histogram.end() && it->second > 0) --it->second; else diff --git a/xfa/fde/css/cfde_cssstylesheet.h b/xfa/fde/css/cfde_cssstylesheet.h index fa73460634..24bebddcbf 100644 --- a/xfa/fde/css/cfde_cssstylesheet.h +++ b/xfa/fde/css/cfde_cssstylesheet.h @@ -7,8 +7,8 @@ #ifndef XFA_FDE_CSS_CFDE_CSSSTYLESHEET_H_ #define XFA_FDE_CSS_CFDE_CSSSTYLESHEET_H_ +#include #include -#include #include #include "core/fxcrt/fx_string.h" @@ -34,7 +34,7 @@ class CFDE_CSSStyleSheet { void SkipRuleSet(CFDE_CSSSyntaxParser* pSyntax); std::vector> m_RuleArray; - std::unordered_map m_StringCache; + std::map m_StringCache; }; #endif // XFA_FDE_CSS_CFDE_CSSSTYLESHEET_H_ diff --git a/xfa/fwl/cfwl_notedriver.h b/xfa/fwl/cfwl_notedriver.h index 2ea3f97cc0..b55e701c40 100644 --- a/xfa/fwl/cfwl_notedriver.h +++ b/xfa/fwl/cfwl_notedriver.h @@ -8,8 +8,8 @@ #define XFA_FWL_CFWL_NOTEDRIVER_H_ #include +#include #include -#include #include #include "xfa/fwl/cfwl_event.h" @@ -69,8 +69,7 @@ class CFWL_NoteDriver { std::vector m_Forms; std::deque> m_NoteQueue; std::vector m_NoteLoopQueue; - std::unordered_map> - m_eventTargets; + std::map> m_eventTargets; CFWL_Widget* m_pHover; CFWL_Widget* m_pFocus; CFWL_Widget* m_pGrab; diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 4b0a398ae2..a1180e7b8e 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -345,7 +345,7 @@ void CXFA_Document::DoProtoMerge() { return; std::map mIDMap; - std::unordered_set sUseNodes; + std::set sUseNodes; CXFA_NodeIterator sIterator(pTemplateRoot); for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; pNode = sIterator.MoveToNext()) { diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 03586b6591..8491febdbf 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include "xfa/fxfa/fxfa.h" @@ -120,7 +120,7 @@ class CXFA_Document { std::unique_ptr m_pScriptLog; std::unique_ptr m_pScriptLayout; std::unique_ptr m_pScriptSignature; - std::unordered_set m_PurgeNodes; + std::set m_PurgeNodes; XFA_VERSION m_eCurVersionMode; uint32_t m_dwDocFlags; }; diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 73fc88db8f..9fae4a43aa 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -90,7 +90,7 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) { } std::vector NodesSortedByDocumentIdx( - const std::unordered_set& rgNodeSet) { + const std::set& rgNodeSet) { if (rgNodeSet.empty()) return std::vector(); @@ -105,8 +105,7 @@ std::vector NodesSortedByDocumentIdx( return rgNodeArray; } -using CXFA_NodeSetPair = - std::pair, std::unordered_set>; +using CXFA_NodeSetPair = std::pair, std::set>; using CXFA_NodeSetPairMap = std::map>; using CXFA_NodeSetPairMapMap = @@ -129,8 +128,8 @@ CXFA_NodeSetPair* NodeSetPairForNode(CXFA_Node* pNode, return (*pNodeSetPairMap)[dwNameHash].get(); } -void ReorderDataNodes(const std::unordered_set& sSet1, - const std::unordered_set& sSet2, +void ReorderDataNodes(const std::set& sSet1, + const std::set& sSet2, bool bInsertBefore) { CXFA_NodeSetPairMapMap rgMap; for (CXFA_Node* pNode : sSet1) { @@ -231,8 +230,8 @@ void InsertItem(CXFA_Node* pInstMgrNode, pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) ->InsertChild(pNewInstance, pNextSibling); if (bMoveDataBindingNodes) { - std::unordered_set sNew; - std::unordered_set sAfter; + std::set sNew; + std::set sAfter; CXFA_NodeIteratorTemplate sIteratorNew(pNewInstance); @@ -262,8 +261,8 @@ void InsertItem(CXFA_Node* pInstMgrNode, pInstMgrNode->GetNodeItem(XFA_NODEITEM_Parent) ->InsertChild(pNewInstance, pBeforeInstance); if (bMoveDataBindingNodes) { - std::unordered_set sNew; - std::unordered_set sBefore; + std::set sNew; + std::set sBefore; CXFA_NodeIteratorTemplate sIteratorNew(pNewInstance); -- cgit v1.2.3