This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Make SmallSet::insert(const T &) return const_iterator
ClosedPublic

Authored by piggynl on Aug 10 2022, 1:17 AM.

Details

Summary

This patch makes SmallSet::insert(const T &) return std::pair<const_iterator, bool> instead of std::pair<NoneType, bool>. This will exactly match std::set's behavior and make deduplicating items with SmallSet easier.

Diff Detail

Event Timeline

piggynl created this revision.Aug 10 2022, 1:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 1:17 AM
piggynl requested review of this revision.Aug 10 2022, 1:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 1:17 AM
piggynl updated this revision to Diff 451392.Aug 10 2022, 2:23 AM
piggynl retitled this revision from [ADT] Make SmallSet().insert(const T &) returns const_iterator to [ADT] Make SmallSet::insert(const T &) returns const_iterator.
piggynl edited the summary of this revision. (Show Details)
piggynl added reviewers: fhahn, lattner, dblaikie.

Update comments.

Sounds OK, with a minor improvement using structured bindings.

llvm/include/llvm/ADT/SmallSet.h
180–182

Could use a structure binding here?

186

Not sure the iterators need to be renamed - they're in distinct scopes and it'd probably be OK for them both to be named I despite them having different types.

lattner accepted this revision.Aug 10 2022, 1:09 PM

nice, thank you for improving this!

This revision is now accepted and ready to land.Aug 10 2022, 1:09 PM
piggynl updated this revision to Diff 451616.Aug 10 2022, 1:27 PM

Revise according to @dblaikie's comments.

This revision was automatically updated to reflect the committed changes.
piggynl marked 2 inline comments as done.
piggynl retitled this revision from [ADT] Make SmallSet::insert(const T &) returns const_iterator to [ADT] Make SmallSet::insert(const T &) return const_iterator.Aug 14 2022, 10:56 PM
piggynl edited the summary of this revision. (Show Details)