aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ADT/DenseMap.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h
index 91f00f99fe..7f02dc92e2 100644
--- a/include/llvm/ADT/DenseMap.h
+++ b/include/llvm/ADT/DenseMap.h
@@ -63,6 +63,8 @@ class DenseMap {
unsigned NumEntries;
unsigned NumTombstones;
public:
+ typedef BucketT value_type;
+
DenseMap(const DenseMap& other) {
NumBuckets = 0;
CopyFrom(other);
@@ -174,13 +176,17 @@ public:
++NumTombstones;
return true;
}
-
- ValueT &operator[](const KeyT &Key) {
+
+ value_type& FindAndConstruct(const KeyT &Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
- return TheBucket->second;
-
- return InsertIntoBucket(Key, ValueT(), TheBucket)->second;
+ return *TheBucket;
+
+ return *InsertIntoBucket(Key, ValueT(), TheBucket);
+ }
+
+ ValueT &operator[](const KeyT &Key) {
+ return FindAndConstruct(Key).second;
}
DenseMap& operator=(const DenseMap& other) {