From 4e3b903a957394e755dd0d3c89c17e9c46ee110e Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 27 Feb 2015 21:43:14 +0000 Subject: [PATCH] Reduce double set lookups. llvm-svn: 230798 --- llvm/include/llvm/ADT/DepthFirstIterator.h | 3 +-- llvm/lib/Analysis/LazyValueInfo.cpp | 3 +-- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/ADT/DepthFirstIterator.h b/llvm/include/llvm/ADT/DepthFirstIterator.h index 6cd9e68..657fe6867 100644 --- a/llvm/include/llvm/ADT/DepthFirstIterator.h +++ b/llvm/include/llvm/ADT/DepthFirstIterator.h @@ -113,9 +113,8 @@ private: while (It != GT::child_end(Node)) { NodeType *Next = *It++; // Has our next sibling been visited? - if (Next && !this->Visited.count(Next)) { + if (Next && this->Visited.insert(Next).second) { // No, do it now. - this->Visited.insert(Next); VisitStack.push_back(std::make_pair(PointerIntTy(Next, 0), GT::child_begin(Next))); return; diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 87c31fd..d4580dc 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -346,11 +346,10 @@ namespace { /// Push BV onto BlockValueStack unless it's already in there. /// Returns true on success. bool pushBlockValue(const std::pair &BV) { - if (BlockValueSet.count(BV)) + if (!BlockValueSet.insert(BV).second) return false; // It's already in the stack. BlockValueStack.push(BV); - BlockValueSet.insert(BV); return true; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index ad7411f..719af41 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -622,8 +622,7 @@ public: void removeValue(const Value *V) { // This is to support hack in lowerCallFromStatepoint // Should be removed when hack is resolved - if (NodeMap.count(V)) - NodeMap.erase(V); + NodeMap.erase(V); } void setUnusedArgValue(const Value *V, SDValue NewN) { -- 2.7.4