diff options
| author | Anders Carlsson <andersca@mac.com> | 2009-12-04 15:49:02 +0000 |
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2009-12-04 15:49:02 +0000 |
| commit | 7bb7076b51b79f55ef260fed5788ef0627b1f65b (patch) | |
| tree | 96c3f40a182537ada8bf4c80e8887a26a5bfc3c2 /clang/lib/CodeGen | |
| parent | 6154dbd5ee47a711223b5f6b9705d04e885223af (diff) | |
| download | bcm5719-llvm-7bb7076b51b79f55ef260fed5788ef0627b1f65b.tar.gz bcm5719-llvm-7bb7076b51b79f55ef260fed5788ef0627b1f65b.zip | |
Change getIndex to return false if the index wasn't found. Avoids an extra hash lookup.
llvm-svn: 90568
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGVtable.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGVtable.cpp b/clang/lib/CodeGen/CGVtable.cpp index 96e5fc58377..e6b37555d65 100644 --- a/clang/lib/CodeGen/CGVtable.cpp +++ b/clang/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 = |

