Index: tools/llvm-exegesis/lib/BitVectorVector.h =================================================================== --- tools/llvm-exegesis/lib/BitVectorVector.h +++ tools/llvm-exegesis/lib/BitVectorVector.h @@ -57,6 +57,14 @@ /// Get a const_iterator to the beginning of the BitVectorVector. const_iterator begin() const { return vector_.begin(); } + /// Assign a range of elements, replacing the existing content. + template void assign(It Start, It End) { + clear(); + vector_.assign(Start, End); + for (const value_type Value : llvm::make_range(Start, End)) + bitvector_.set(Value); + } + /// Insert a range of elements into the BitVectorVector. template void insert(It Start, It End) { for (; Start != End; ++Start) { Index: tools/llvm-exegesis/lib/Clustering.cpp =================================================================== --- tools/llvm-exegesis/lib/Clustering.cpp +++ tools/llvm-exegesis/lib/Clustering.cpp @@ -112,8 +112,7 @@ CurrentCluster.PointIndices.push_back(P); // Process P's neighbors. - ToProcess.clear(); - ToProcess.insert(Neighbors.begin(), Neighbors.end()); + ToProcess.assign(Neighbors.begin(), Neighbors.end()); while (!ToProcess.empty()) { // Retrieve a point from the set. const size_t Q = *ToProcess.begin();