[Mlir-commits] [clang] [lld] [llvm] [mlir] [polly] [SetVector] Make SetVector::insert consistent (NFC) (PR #232372)
Jay Foad
llvmlistbot at llvm.org
Fri Oct 16 04:41:17 PDT 2026
================
@@ -153,23 +153,26 @@ class SetVector {
}
/// Insert a new element into the SetVector.
- /// \returns true if the element was inserted into the SetVector.
- bool insert(const value_type &X) {
+ /// \returns a pair, whose first member is the iterator pointed to the
+ /// element, and the second member indicates if the element was inserted.
+ std::pair<iterator, bool> insert(const value_type &X) {
if constexpr (canBeSmall())
if (isSmall()) {
if (!llvm::is_contained(vector_, X)) {
vector_.push_back(X);
if (vector_.size() > N)
makeBig();
- return true;
+ return {std::prev(vector_.end()), true};
}
- return false;
+ return {find(vector_, X), false};
----------------
jayfoad wrote:
Doesn't the llvm::is_contained above already do one linear scan through the vector? So we should not call find() here which will do a second linear scan.
https://github.com/llvm/llvm-project/pull/232372
More information about the Mlir-commits
mailing list