[llvm-commits] CVS: llvm/lib/Support/StringMap.cpp

Chris Lattner sabre at nondot.org
Tue Apr 3 17:44:53 PDT 2007



Changes in directory llvm/lib/Support:

StringMap.cpp updated: 1.11 -> 1.12
---
Log message:

use calloc instead of new/memset, it is more efficient


---
Diffs of the changes:  (+2 -4)

 StringMap.cpp |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)


Index: llvm/lib/Support/StringMap.cpp
diff -u llvm/lib/Support/StringMap.cpp:1.11 llvm/lib/Support/StringMap.cpp:1.12
--- llvm/lib/Support/StringMap.cpp:1.11	Tue Apr  3 19:29:37 2007
+++ llvm/lib/Support/StringMap.cpp	Tue Apr  3 19:44:31 2007
@@ -38,8 +38,7 @@
   NumItems = 0;
   NumTombstones = 0;
   
-  TheTable = new ItemBucket[NumBuckets+1]();
-  memset(TheTable, 0, NumBuckets*sizeof(ItemBucket));
+  TheTable = (ItemBucket*)calloc(NumBuckets+1, sizeof(ItemBucket));
   
   // Allocate one extra bucket, set it to look filled so the iterators stop at
   // end.
@@ -200,8 +199,7 @@
   unsigned NewSize = NumBuckets*2;
   // Allocate one extra bucket which will always be non-empty.  This allows the
   // iterators to stop at end.
-  ItemBucket *NewTableArray = new ItemBucket[NewSize+1]();
-  memset(NewTableArray, 0, NewSize*sizeof(ItemBucket));
+  ItemBucket *NewTableArray =(ItemBucket*)calloc(NewSize+1, sizeof(ItemBucket));
   NewTableArray[NewSize].Item = (StringMapEntryBase*)2;
   
   // Rehash all the items into their new buckets.  Luckily :) we already have






More information about the llvm-commits mailing list