================ @@ -61,7 +61,28 @@ class ParentMapContext::ParentMap { template <typename, typename...> friend struct ::MatchParents; /// Contains parents of a node. - using ParentVector = llvm::SmallVector<DynTypedNode, 2>; + class ParentVector { + public: + ParentVector() = default; + explicit ParentVector(size_t n, const DynTypedNode &value) { + Items.reserve(n); + for (; n > 0; --n) { + push_back(value); + } + } + bool contains(const DynTypedNode &value) { + return Seen.contains(value); + } + void push_back(const DynTypedNode &value) { + if (!value.getMemoizationData() || Seen.insert(value).second) { + Items.push_back(value); + } ---------------- higher-performance wrote:
Thank you! Applied the suggestion. Regarding the `push_back`, I don't believe you can use `std::fill_n` to fill the items directly, due to the additional checks that first occur inside `push_back`. (I could've optimized that away by lifting out the checks, but that didn't seem worthwhile vs. the clarity.) https://github.com/llvm/llvm-project/pull/87824 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits