Skip to content

Commit 3b703d4

Browse files
[Bitcode] Use DenseSet instead of std::set (NFC) (#105851)
DefOrUseGUIDs is used only for membership checking purposes. We don't need std::set's strengths like iterators staying valid or the ability to traverse in a sorted order. While I am at it, this patch replaces count with contains for slightly increased readability.
1 parent 64afbf0 commit 3b703d4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4628,7 +4628,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
46284628
NameVals.clear();
46294629
};
46304630

4631-
std::set<GlobalValue::GUID> DefOrUseGUIDs;
4631+
DenseSet<GlobalValue::GUID> DefOrUseGUIDs;
46324632
forEachSummary([&](GVInfo I, bool IsAliasee) {
46334633
GlobalValueSummary *S = I.second;
46344634
assert(S);
@@ -4777,7 +4777,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
47774777

47784778
if (!Index.cfiFunctionDefs().empty()) {
47794779
for (auto &S : Index.cfiFunctionDefs()) {
4780-
if (DefOrUseGUIDs.count(
4780+
if (DefOrUseGUIDs.contains(
47814781
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
47824782
NameVals.push_back(StrtabBuilder.add(S));
47834783
NameVals.push_back(S.size());
@@ -4791,7 +4791,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
47914791

47924792
if (!Index.cfiFunctionDecls().empty()) {
47934793
for (auto &S : Index.cfiFunctionDecls()) {
4794-
if (DefOrUseGUIDs.count(
4794+
if (DefOrUseGUIDs.contains(
47954795
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S)))) {
47964796
NameVals.push_back(StrtabBuilder.add(S));
47974797
NameVals.push_back(S.size());

0 commit comments

Comments
 (0)