llvm.org GIT mirror llvm / d2f197d
use calloc instead of new/memset, it is more efficient git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35644 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
2 changed file(s) with 3 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
278278 if (I->Item && I->Item != getTombstoneVal())
279279 static_cast(I->Item)->Destroy(Allocator);
280280 }
281 delete [] TheTable;
281 free(TheTable);
282282 }
283283 };
284284
3737 NumItems = 0;
3838 NumTombstones = 0;
3939
40 TheTable = new ItemBucket[NumBuckets+1]();
41 memset(TheTable, 0, NumBuckets*sizeof(ItemBucket));
40 TheTable = (ItemBucket*)calloc(NumBuckets+1, sizeof(ItemBucket));
4241
4342 // Allocate one extra bucket, set it to look filled so the iterators stop at
4443 // end.
199198 unsigned NewSize = NumBuckets*2;
200199 // Allocate one extra bucket which will always be non-empty. This allows the
201200 // iterators to stop at end.
202 ItemBucket *NewTableArray = new ItemBucket[NewSize+1]();
203 memset(NewTableArray, 0, NewSize*sizeof(ItemBucket));
201 ItemBucket *NewTableArray =(ItemBucket*)calloc(NewSize+1, sizeof(ItemBucket));
204202 NewTableArray[NewSize].Item = (StringMapEntryBase*)2;
205203
206204 // Rehash all the items into their new buckets. Luckily :) we already have