[all-commits] [llvm/llvm-project] ff2250: [NFC][llvm][StringMap]Extract createTable and getH...
wangyihan via All-commits
all-commits at lists.llvm.org
Tue Mar 22 19:11:54 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ff225019f015b12b31f657b98cfcf0684ab446f8
https://github.com/llvm/llvm-project/commit/ff225019f015b12b31f657b98cfcf0684ab446f8
Author: wangyihan <1135831309 at qq.com>
Date: 2022-03-23 (Wed, 23 Mar 2022)
Changed paths:
M llvm/lib/Support/StringMap.cpp
Log Message:
-----------
[NFC][llvm][StringMap]Extract createTable and getHashTable functions and add the inline attribute to the getMinBucketToReserveForEntries function.
1. Extract createTable and getHashTable functions.
2. Add the inline attribute to the getMinBucketToReserveForEntries function.
3. Remove unnecessary local variable HTSize.
Statements in the following order appear in llvm::StringMapImpl::init and llvm::StringMapImpl::RehashTable, so I extracted this code into a function. getHashTable is for the same reason, it appears in llvm::StringMapImpl::FindKey, llvm::StringMapImpl::LookupBucketFor and llvm::StringMapImpl::RehashTable.
```
auto **Table = static_cast<StringMapEntryBase **>(safe_calloc(
NewNumBuckets + 1, sizeof(StringMapEntryBase **) + sizeof(unsigned)));
// Allocate one extra bucket, set it to look filled so the iterators stop at
// end.
Table[NewNumBuckets] = (StringMapEntryBase *)2;
```
```
unsigned *HashTable = (unsigned *)(TheTable + NumBuckets + 1);
```
Reviewed By: skan, sepavloff
Differential Revision: https://reviews.llvm.org/D121934
More information about the All-commits
mailing list