diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-26 04:07:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-26 04:07:12 +0000 |
commit | 00fa65be8344944b080cd790678e027e10942ffd (patch) | |
tree | aef439b703531be5e0bade494e827436f5a2f83a | |
parent | af6926a3824742cce18b626ed6ca6ec83b29c0a3 (diff) |
Fix typeo. grow() cannot shrink storage. clear() should really nuke storage
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11865 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/Support/DenseMap.h | 8 | ||||
-rw-r--r-- | include/llvm/ADT/DenseMap.h | 8 | ||||
-rw-r--r-- | include/llvm/ADT/IndexedMap.h | 8 |
3 files changed, 15 insertions, 9 deletions
diff --git a/include/Support/DenseMap.h b/include/Support/DenseMap.h index 5fcdfae9de..9d713d97c3 100644 --- a/include/Support/DenseMap.h +++ b/include/Support/DenseMap.h @@ -9,7 +9,7 @@ // // This file implements a dense map. A dense map template takes two // types. The first is the mapped type and the second is a functor -// that maps its argument to a size_t. On instanciation a "null" value +// that maps its argument to a size_t. On instantiation a "null" value // can be provided to be used as a "does not exist" indicator in the // map. A member function grow() is provided that given the value of // the maximally indexed key (the argument of the functor) makes sure @@ -48,11 +48,13 @@ public: } void clear() { - storage_.assign(storage_.size(), nullVal_); + storage_.clear(); } void grow(IndexT n) { - storage_.resize(toIndex_(n) + 1, nullVal_); + unsigned NewSize = toIndex_(n) + 1; + if (NewSize > storage_.size()) + storage_.resize(NewSize, nullVal_); } }; diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index 5fcdfae9de..9d713d97c3 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -9,7 +9,7 @@ // // This file implements a dense map. A dense map template takes two // types. The first is the mapped type and the second is a functor -// that maps its argument to a size_t. On instanciation a "null" value +// that maps its argument to a size_t. On instantiation a "null" value // can be provided to be used as a "does not exist" indicator in the // map. A member function grow() is provided that given the value of // the maximally indexed key (the argument of the functor) makes sure @@ -48,11 +48,13 @@ public: } void clear() { - storage_.assign(storage_.size(), nullVal_); + storage_.clear(); } void grow(IndexT n) { - storage_.resize(toIndex_(n) + 1, nullVal_); + unsigned NewSize = toIndex_(n) + 1; + if (NewSize > storage_.size()) + storage_.resize(NewSize, nullVal_); } }; diff --git a/include/llvm/ADT/IndexedMap.h b/include/llvm/ADT/IndexedMap.h index 5fcdfae9de..9d713d97c3 100644 --- a/include/llvm/ADT/IndexedMap.h +++ b/include/llvm/ADT/IndexedMap.h @@ -9,7 +9,7 @@ // // This file implements a dense map. A dense map template takes two // types. The first is the mapped type and the second is a functor -// that maps its argument to a size_t. On instanciation a "null" value +// that maps its argument to a size_t. On instantiation a "null" value // can be provided to be used as a "does not exist" indicator in the // map. A member function grow() is provided that given the value of // the maximally indexed key (the argument of the functor) makes sure @@ -48,11 +48,13 @@ public: } void clear() { - storage_.assign(storage_.size(), nullVal_); + storage_.clear(); } void grow(IndexT n) { - storage_.resize(toIndex_(n) + 1, nullVal_); + unsigned NewSize = toIndex_(n) + 1; + if (NewSize > storage_.size()) + storage_.resize(NewSize, nullVal_); } }; |