Change getIndex to return false if the index wasn't found. Avoids an extra hash lookup.

llvm-svn: 90568
This commit is contained in:
Anders Carlsson 2009-12-04 15:49:02 +00:00
parent 6154dbd5ee
commit 7bb7076b51
1 changed files with 11 additions and 10 deletions

View File

@ -91,15 +91,17 @@ private:
MethodToIndexMap[GD] = Index; MethodToIndexMap[GD] = Index;
} }
bool hasIndex(GlobalDecl GD) const { /// getIndex - Gives the index of a passed in GlobalDecl. Returns false if
return MethodToIndexMap.count(GD); /// the index couldn't be found.
} uint64_t getIndex(GlobalDecl GD, uint64_t &Index) const {
llvm::DenseMap<GlobalDecl, uint64_t>::const_iterator i
= MethodToIndexMap.find(GD);
/// getIndex - Returns the index of the given method. if (i == MethodToIndexMap.end())
uint64_t getIndex(GlobalDecl GD) const { return false;
assert(MethodToIndexMap.count(GD) && "Did not find method!");
return MethodToIndexMap.lookup(GD); Index = i->second;
return true;
} }
MethodsVectorTy::size_type size() const { MethodsVectorTy::size_type size() const {
@ -741,11 +743,10 @@ bool VtableBuilder::OverrideMethod(GlobalDecl GD, bool MorallyVirtual,
OGD = OMD; OGD = OMD;
// FIXME: Explain why this is necessary! // FIXME: Explain why this is necessary!
if (!Methods.hasIndex(OGD)) uint64_t Index;
if (!Methods.getIndex(OGD, Index))
continue; continue;
uint64_t Index = Methods.getIndex(OGD);
QualType ReturnType = QualType ReturnType =
MD->getType()->getAs<FunctionType>()->getResultType(); MD->getType()->getAs<FunctionType>()->getResultType();
QualType OverriddenReturnType = QualType OverriddenReturnType =