From c418bf3dd593b5b2fe2f978930f6d0d6b17e344e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 11 Jul 2008 20:58:19 +0000 Subject: [PATCH] Use find instead of lower_bound. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53474 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopInfo.h | 4 ++-- lib/Analysis/LoadValueNumbering.cpp | 4 ++-- lib/Support/Timer.cpp | 4 ++-- lib/Transforms/IPO/GlobalDCE.cpp | 4 ++-- lib/VMCore/Constants.cpp | 9 ++++----- lib/VMCore/Type.cpp | 8 ++++---- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index ff2c3caf5b0..e22f22f0702 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -823,8 +823,8 @@ public: for (typename std::vector::iterator I = L->Blocks.begin(), E = L->Blocks.end(); I != E; ++I) { typename std::map*>::iterator BBMI = - BBMap.lower_bound(*I); - if (BBMI == BBMap.end() || BBMI->first != *I) // Not in map yet... + BBMap.find(*I); + if (BBMI == BBMap.end()) // Not in map yet... BBMap.insert(BBMI, std::make_pair(*I, L)); // Must be at this level } diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index 2414d33863d..f99ebb4a83d 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -117,9 +117,9 @@ static bool isPathTransparentTo(BasicBlock *CurBlock, BasicBlock *Dom, // Check whether this block is known transparent or not. std::map::iterator TBI = - TransparentBlocks.lower_bound(CurBlock); + TransparentBlocks.find(CurBlock); - if (TBI == TransparentBlocks.end() || TBI->first != CurBlock) { + if (TBI == TransparentBlocks.end()) { // If this basic block can modify the memory location, then the path is not // transparent! if (AA.canBasicBlockModify(*CurBlock, Ptr, Size)) { diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index c8678d3ae2c..29fd00c0a33 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -185,8 +185,8 @@ void Timer::addPeakMemoryMeasurement() { static ManagedStatic > NamedTimers; static Timer &getNamedRegionTimer(const std::string &Name) { - std::map::iterator I = NamedTimers->lower_bound(Name); - if (I != NamedTimers->end() && I->first == Name) + std::map::iterator I = NamedTimers->find(Name); + if (I != NamedTimers->end()) return I->second; return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second; diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 98202eb0b34..608705b10a0 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -134,10 +134,10 @@ bool GlobalDCE::runOnModule(Module &M) { /// MarkGlobalIsNeeded - the specific global value as needed, and /// recursively mark anything that it uses as also needed. void GlobalDCE::GlobalIsNeeded(GlobalValue *G) { - std::set::iterator I = AliveGlobals.lower_bound(G); + std::set::iterator I = AliveGlobals.find(G); // If the global is already in the set, no need to reprocess it. - if (I != AliveGlobals.end() && *I == G) return; + if (I != AliveGlobals.end()) return; // Otherwise insert it now, so we do not infinitely recurse AliveGlobals.insert(I, G); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index dc9cab032c5..a1158e34de1 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1100,9 +1100,9 @@ public: /// necessary. ConstantClass *getOrCreate(const TypeClass *Ty, const ValType &V) { MapKey Lookup(Ty, V); - typename MapTy::iterator I = Map.lower_bound(Lookup); + typename MapTy::iterator I = Map.find(Lookup); // Is it in the map? - if (I != Map.end() && I->first == Lookup) + if (I != Map.end()) return static_cast(I->second); // If no preexisting value, create one now... @@ -1119,10 +1119,9 @@ public: // If the type of the constant is abstract, make sure that an entry exists // for it in the AbstractTypeMap. if (Ty->isAbstract()) { - typename AbstractTypeMapTy::iterator TI = - AbstractTypeMap.lower_bound(Ty); + typename AbstractTypeMapTy::iterator TI = AbstractTypeMap.find(Ty); - if (TI == AbstractTypeMap.end() || TI->first != Ty) { + if (TI == AbstractTypeMap.end()) { // Add ourselves to the ATU list of the type. cast(Ty)->addAbstractTypeUser(this); diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 90258edbda2..a05f911e83f 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -251,8 +251,8 @@ static std::string getTypeDescription(const Type *Ty, std::vector &TypeStack) { if (isa(Ty)) { // Base case for the recursion std::map::iterator I = - AbstractTypeDescriptions->lower_bound(Ty); - if (I != AbstractTypeDescriptions->end() && I->first == Ty) + AbstractTypeDescriptions->find(Ty); + if (I != AbstractTypeDescriptions->end()) return I->second; std::string Desc = "opaque"; AbstractTypeDescriptions->insert(std::make_pair(Ty, Desc)); @@ -655,8 +655,8 @@ static bool TypesEqual(const Type *Ty, const Type *Ty2, if (isa(Ty)) return false; // Two unequal opaque types are never equal - std::map::iterator It = EqTypes.lower_bound(Ty); - if (It != EqTypes.end() && It->first == Ty) + std::map::iterator It = EqTypes.find(Ty); + if (It != EqTypes.end()) return It->second == Ty2; // Looping back on a type, check for equality // Otherwise, add the mapping to the table to make sure we don't get -- 2.34.1