The m_objects store in ClusterManager holds pointers to all the objects
managed by the ClusterManager. It is used to check whether
this ClusterManager already owns this pointer before adding it to
the ClusterManager's shared pointer or getting the shared pointer for the object.
When the ClusterManager is deleted, we iterate over it to destroy all the managed objects.
The most common operation by far is "GetSharedPointer" on the cluster.
With a SmallVector and llvm::is_contained the performance was non-linear
in the number of elements. For instance, printing all the elements of a 16M element std::vector
didn't complete in the time I was willing to wait for it (hours).
Since we are mostly doing insert & contains, some kind of set is likely to be a
better data structure. In this patch I used SmallPtrSet. With
that, the same array prints out in 30 seconds. I couldn't see any noticeable difference
for ValueObjects with a small number of children. I also tried a the same patch using a
std::unordered_set but that was slightly slower and used a fair bit
more memory than the SmallPtrSet.
Other than performance, this is NFC.
I assume pointers cannot be modified once they're in the set. Can this be const T *?