This is an archive of the discontinued LLVM Phabricator instance.

[llvm][ADT]Remove duplicate code in llvm::StringMapImpl::RehashTable
ClosedPublic

Authored by yihanaa on Mar 15 2022, 11:52 AM.

Details

Summary

remove duplicate code in llvm::StringMapImpl::RehashTable, near StringMap.cpp:229

if (!NewTableArray[NewBucket]) {
        NewTableArray[FullHash & (NewSize - 1)] = Bucket;
        NewHashArray[FullHash & (NewSize - 1)] = FullHash;
        if (I == BucketNo)
          NewBucketNo = NewBucket;
        continue;
}

Diff Detail

Event Timeline

yihanaa created this revision.Mar 15 2022, 11:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 11:52 AM
yihanaa requested review of this revision.Mar 15 2022, 11:52 AM
MaskRay accepted this revision.Mar 15 2022, 12:25 PM

Looks great!

This revision is now accepted and ready to land.Mar 15 2022, 12:25 PM
dexonsmith accepted this revision.Mar 15 2022, 1:12 PM

LGTM too, assuming you fix the comment, which I think is now backwards (doesn't have to be the wording I suggested inline).

llvm/lib/Support/StringMap.cpp
229–236

I think the comment is backwards now!

I suggest:

// If the bucket is not available, probe for a spot.
238–239

Note that clang-format wants you to do something here.

yihanaa updated this revision to Diff 415645.Mar 15 2022, 5:19 PM
yihanaa marked an inline comment as done.

i quite agree with @dexonsmith , and reformatted the code with clang-format

yihanaa marked an inline comment as done.Mar 15 2022, 5:23 PM

Looks great!

Thanks @MaskRay . I don’t have commit access, can you land this patch for me? Please use “wangyihan 1135831309@qq.com” to commit the change.

yihanaa requested review of this revision.Mar 15 2022, 8:23 PM
This revision was not accepted when it landed; it landed in state Needs Review.Mar 16 2022, 1:01 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.