aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGVtable.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-12-04 15:49:02 +0000
committerAnders Carlsson <andersca@mac.com>2009-12-04 15:49:02 +0000
commit77c23e5a49c30f829bf041a88ad6c60e6b662cc9 (patch)
tree2ccb9c1c57e199ce80490ba9101cbb155a0e4e52 /lib/CodeGen/CGVtable.cpp
parentdfe33bbd41959dba8ce45f21db5f09badde5bf60 (diff)
Change getIndex to return false if the index wasn't found. Avoids an extra hash lookup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90568 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVtable.cpp')
-rw-r--r--lib/CodeGen/CGVtable.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/CodeGen/CGVtable.cpp b/lib/CodeGen/CGVtable.cpp
index 96e5fc5837..e6b37555d6 100644
--- a/lib/CodeGen/CGVtable.cpp
+++ b/lib/CodeGen/CGVtable.cpp
@@ -91,15 +91,17 @@ private:
MethodToIndexMap[GD] = Index;
}
- bool hasIndex(GlobalDecl GD) const {
- return MethodToIndexMap.count(GD);
- }
-
- /// getIndex - Returns the index of the given method.
- uint64_t getIndex(GlobalDecl GD) const {
- assert(MethodToIndexMap.count(GD) && "Did not find method!");
+ /// 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);
+
+ 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 =