[llvm-commits] CVS: llvm/include/Support/DenseMap.h

Chris Lattner lattner at cs.uiuc.edu
Wed Feb 25 22:08:00 PST 2004


Changes in directory llvm/include/Support:

DenseMap.h updated: 1.1 -> 1.2

---
Log message:

Fix typeo.  grow() cannot shrink storage.  clear() should really nuke storage


---
Diffs of the changes:  (+5 -3)

Index: llvm/include/Support/DenseMap.h
diff -u llvm/include/Support/DenseMap.h:1.1 llvm/include/Support/DenseMap.h:1.2
--- llvm/include/Support/DenseMap.h:1.1	Wed Feb 25 15:55:45 2004
+++ llvm/include/Support/DenseMap.h	Wed Feb 25 22:07:12 2004
@@ -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 @@
     }
 
     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_);
     }
 };
 





More information about the llvm-commits mailing list