This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][NFC] Use llvm::is_contained
ClosedPublic

Authored by Amir on Mar 6 2023, 9:00 PM.

Details

Reviewers
rafauler
maksfb
Group Reviewers
Restricted Project
Commits
rG2eae9d8eb2f6: [BOLT][NFC] Use llvm::is_contained
Summary

Apply the replacement throughout BOLT.

Diff Detail

Event Timeline

Amir created this revision.Mar 6 2023, 9:00 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Amir requested review of this revision.Mar 6 2023, 9:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 9:00 PM
This revision is now accepted and ready to land.Mar 14 2023, 2:47 PM
This revision was automatically updated to reflect the committed changes.
kuhar added a subscriber: kuhar.Mar 14 2023, 3:42 PM

FYI, by a quick scan through the patch, it seems like a likely pessimization. Currently, llvm::is_contained performs a linear scan to find the element, while .find(x) is typically O(1) or O(log n). Related discussion on this topic: https://reviews.llvm.org/D146061

Amir added a comment.Mar 14 2023, 3:51 PM

FYI, by a quick scan through the patch, it seems like a likely pessimization. Currently, llvm::is_contained performs a linear scan to find the element, while .find(x) is typically O(1) or O(log n). Related discussion on this topic: https://reviews.llvm.org/D146061

Thanks for a heads up! It'd be great to specialize is_contained for const- or log-time lookup.