From 92b54029289a312d5dbb5e1d7dc4a8e9b8c73db4 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 20 May 2016 13:58:28 -0700 Subject: Use std::set to track uniqueness in xfa_script_layoutpseudomodel.cpp Review-Url: https://codereview.chromium.org/2001743002 --- xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp | 39 +++++++++++------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp index e48d3d5ffa..ffb3a9e588 100644 --- a/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/xfa_script_layoutpseudomodel.cpp @@ -6,6 +6,9 @@ #include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" +#include + +#include "third_party/base/stl_util.h" #include "xfa/fxfa/app/xfa_ffnotify.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" #include "xfa/fxfa/parser/xfa_doclayout.h" @@ -232,8 +235,7 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( } return; } - CFX_MapPtrToPtr formItems; - formItems.InitHashTable(256, TRUE); + std::set formItems; if (wsType.IsEmpty()) { if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { retArray.Add(pMasterPage); @@ -258,10 +260,10 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( eElementType != XFA_ELEMENT_Area) { continue; } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); + + formItems.insert(pItemChild->m_pFormNode); retArray.Add(pItemChild->m_pFormNode); } } @@ -282,10 +284,9 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( eElementType != XFA_ELEMENT_Area) { continue; } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); + formItems.insert(pItemChild->m_pFormNode); retArray.Add(pItemChild->m_pFormNode); } } @@ -313,16 +314,13 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); pItemChild; pItemChild = iterator.MoveToNext()) { - if (!pItemChild->IsContentLayoutItem()) { + if (!pItemChild->IsContentLayoutItem()) continue; - } - if (pItemChild->m_pFormNode->GetClassID() != eType) { + if (pItemChild->m_pFormNode->GetClassID() != eType) continue; - } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); + formItems.insert(pItemChild->m_pFormNode); retArray.Add(pItemChild->m_pFormNode); } } @@ -333,16 +331,13 @@ void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_GetObjArray( iterator((CXFA_ContentLayoutItem*)pItem); for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); pItemChild; pItemChild = iterator.MoveToNext()) { - if (!pItemChild->IsContentLayoutItem()) { + if (!pItemChild->IsContentLayoutItem()) continue; - } - if (pItemChild->m_pFormNode->GetClassID() != eType) { + if (pItemChild->m_pFormNode->GetClassID() != eType) continue; - } - if (formItems.GetValueAt(pItemChild->m_pFormNode)) { + if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) continue; - } - formItems.SetAt(pItemChild->m_pFormNode, this); + formItems.insert(pItemChild->m_pFormNode); retArray.Add(pItemChild->m_pFormNode); } } -- cgit v1.2.3