-
Notifications
You must be signed in to change notification settings - Fork 15k
StringMap: Remove redundant member init in constructor #149491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StringMap: Remove redundant member init in constructor #149491
Conversation
These are already zeroinitialized in the field definitions.
@llvm/pr-subscribers-llvm-support Author: Matt Arsenault (arsenm) ChangesThese are already zeroinitialized in the field definitions. Full diff: https://github.com/llvm/llvm-project/pull/149491.diff 1 Files Affected:
diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp
index 432e1fc343f1f..3432dc15ceef2 100644
--- a/llvm/lib/Support/StringMap.cpp
+++ b/llvm/lib/Support/StringMap.cpp
@@ -45,23 +45,15 @@ static inline unsigned *getHashTable(StringMapEntryBase **TheTable,
uint32_t StringMapImpl::hash(StringRef Key) { return xxh3_64bits(Key); }
-StringMapImpl::StringMapImpl(unsigned InitSize, unsigned itemSize) {
- ItemSize = itemSize;
-
+StringMapImpl::StringMapImpl(unsigned InitSize, unsigned itemSize)
+ : ItemSize(itemSize) {
// If a size is specified, initialize the table with that many buckets.
if (InitSize) {
// The table will grow when the number of entries reach 3/4 of the number of
// buckets. To guarantee that "InitSize" number of entries can be inserted
// in the table without growing, we allocate just what is needed here.
init(getMinBucketToReserveForEntries(InitSize));
- return;
}
-
- // Otherwise, initialize it with zero buckets to avoid the allocation.
- TheTable = nullptr;
- NumBuckets = 0;
- NumItems = 0;
- NumTombstones = 0;
}
void StringMapImpl::init(unsigned InitSize) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/116/builds/15792 Here is the relevant piece of the build log for the reference
|
These are already zeroinitialized in the field definitions.