diff --git a/lldb/include/lldb/Utility/SharedCluster.h b/lldb/include/lldb/Utility/SharedCluster.h --- a/lldb/include/lldb/Utility/SharedCluster.h +++ b/lldb/include/lldb/Utility/SharedCluster.h @@ -11,7 +11,7 @@ #include "lldb/Utility/LLDBAssert.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/SmallPtrSet.h" #include #include @@ -32,15 +32,15 @@ void ManageObject(T *new_object) { std::lock_guard guard(m_mutex); - assert(!llvm::is_contained(m_objects, new_object) && - "ManageObject called twice for the same object?"); - m_objects.push_back(new_object); + auto ret = m_objects.insert(new_object); + assert(ret.second && "ManageObject called twice for the same object?"); } std::shared_ptr GetSharedPointer(T *desired_object) { std::lock_guard guard(m_mutex); auto this_sp = this->shared_from_this(); - if (!llvm::is_contained(m_objects, desired_object)) { + size_t count = m_objects.count(desired_object); + if (count == 0) { lldbassert(false && "object not found in shared cluster when expected"); desired_object = nullptr; } @@ -49,8 +49,7 @@ private: ClusterManager() : m_objects() {} - - llvm::SmallVector m_objects; + llvm::SmallPtrSet m_objects; std::mutex m_mutex; };