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;
}
bool hasIndex(GlobalDecl GD) const {
return MethodToIndexMap.count(GD);
}
/// getIndex - Gives the index of a passed in GlobalDecl. Returns false if
/// 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.
uint64_t getIndex(GlobalDecl GD) const {
assert(MethodToIndexMap.count(GD) && "Did not find method!");
if (i == MethodToIndexMap.end())
return false;
return MethodToIndexMap.lookup(GD);
Index = i->second;
return true;
}
MethodsVectorTy::size_type size() const {
@ -741,11 +743,10 @@ bool VtableBuilder::OverrideMethod(GlobalDecl GD, bool MorallyVirtual,
OGD = OMD;
// FIXME: Explain why this is necessary!
if (!Methods.hasIndex(OGD))
uint64_t Index;
if (!Methods.getIndex(OGD, Index))
continue;
uint64_t Index = Methods.getIndex(OGD);
QualType ReturnType =
MD->getType()->getAs<FunctionType>()->getResultType();
QualType OverriddenReturnType =