diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-28 09:56:48 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-28 17:16:44 +0000 |
commit | 7cdc660683c233787f18fccf0b63882eec097050 (patch) | |
tree | d0085a4b6782cd0af77c5f36ab37444da1d56b99 /xfa/fxfa/parser/cxfa_node.cpp | |
parent | eed6421dc45a5cc74986b2ef0870974c829f829e (diff) | |
download | pdfium-7cdc660683c233787f18fccf0b63882eec097050.tar.xz |
Remove CFX_ArrayTemplate from CXFA_Node.
Remove some unused arrays from helper functions while we're
at it.
Change-Id: I7cf9efaeb269df8b9c32b128fc9595682102f0e1
Reviewed-on: https://pdfium-review.googlesource.com/3240
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 509decd037..a1074b9ef2 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -81,29 +81,20 @@ int32_t GetCount(CXFA_Node* pInstMgrNode) { return iCount; } -void SortNodeArrayByDocumentIdx(const std::unordered_set<CXFA_Node*>& rgNodeSet, - std::vector<CXFA_Node*>& rgNodeArray, - CFX_ArrayTemplate<int32_t>& rgIdxArray) { - int32_t iCount = pdfium::CollectionSize<int32_t>(rgNodeSet); - rgNodeArray.resize(iCount); - rgIdxArray.SetSize(iCount); - if (iCount == 0) - return; +std::vector<CXFA_Node*> NodesSortedByDocumentIdx( + const std::unordered_set<CXFA_Node*>& rgNodeSet) { + if (rgNodeSet.empty()) + return std::vector<CXFA_Node*>(); - int32_t iIndex = -1; - int32_t iTotalIndex = -1; + std::vector<CXFA_Node*> rgNodeArray; CXFA_Node* pCommonParent = (*rgNodeSet.begin())->GetNodeItem(XFA_NODEITEM_Parent); for (CXFA_Node* pNode = pCommonParent->GetNodeItem(XFA_NODEITEM_FirstChild); - pNode && iIndex < iCount; - pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - iTotalIndex++; - if (pdfium::ContainsValue(rgNodeSet, pNode)) { - iIndex++; - rgNodeArray[iIndex] = pNode; - rgIdxArray[iIndex] = iTotalIndex; - } + pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { + if (pdfium::ContainsValue(rgNodeSet, pNode)) + rgNodeArray.push_back(pNode); } + return rgNodeArray; } using CXFA_NodeSetPair = @@ -158,26 +149,21 @@ void ReorderDataNodes(const std::unordered_set<CXFA_Node*>& sSet1, if (!pNodeSetPair) continue; if (!pNodeSetPair->first.empty() && !pNodeSetPair->second.empty()) { - std::vector<CXFA_Node*> rgNodeArray1; - std::vector<CXFA_Node*> rgNodeArray2; - CFX_ArrayTemplate<int32_t> rgIdxArray1; - CFX_ArrayTemplate<int32_t> rgIdxArray2; - SortNodeArrayByDocumentIdx(pNodeSetPair->first, rgNodeArray1, - rgIdxArray1); - SortNodeArrayByDocumentIdx(pNodeSetPair->second, rgNodeArray2, - rgIdxArray2); + std::vector<CXFA_Node*> rgNodeArray1 = + NodesSortedByDocumentIdx(pNodeSetPair->first); + std::vector<CXFA_Node*> rgNodeArray2 = + NodesSortedByDocumentIdx(pNodeSetPair->second); CXFA_Node* pParentNode = nullptr; CXFA_Node* pBeforeNode = nullptr; if (bInsertBefore) { - pBeforeNode = rgNodeArray2[0]; + pBeforeNode = rgNodeArray2.front(); pParentNode = pBeforeNode->GetNodeItem(XFA_NODEITEM_Parent); } else { - CXFA_Node* pLastNode = rgNodeArray2[rgIdxArray2.GetSize() - 1]; + CXFA_Node* pLastNode = rgNodeArray2.back(); pParentNode = pLastNode->GetNodeItem(XFA_NODEITEM_Parent); pBeforeNode = pLastNode->GetNodeItem(XFA_NODEITEM_NextSibling); } - for (int32_t iIdx = 0; iIdx < rgIdxArray1.GetSize(); iIdx++) { - CXFA_Node* pCurNode = rgNodeArray1[iIdx]; + for (auto* pCurNode : rgNodeArray1) { pParentNode->RemoveChild(pCurNode); pParentNode->InsertChild(pCurNode, pBeforeNode); } |