[clang] [Clang] Dump minimization hints for namespaces (PR #151534)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 1 05:00:16 PDT 2025
================
@@ -188,10 +205,49 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
private:
std::vector<const Decl *> PendingDecls;
+ llvm::DenseSet<const NamespaceDecl *> ProcessedNamespaces;
----------------
ilya-biryukov wrote:
There is a misunderstanding. The documentation says:
> DenseSet is a simple **quadratically probed** hash table.
So it would only be quadratic if the hash function is bad (which is not the case for pointers), otherwise it's amortized `O(1)` like one would expect.
The documentation does seem to suggest that `SmallPtrSet` is a better alternative, so I have switched to it. I am using the size `0`, though, because I anticipate that the number of namespaces we put is going to be quite large on average and the small-set optimization is not going to be useful.
`std::set` would be my last choice as it definitely underperforms compared to both alternatives, the hash tables are just so much faster in those cases in practice.
https://github.com/llvm/llvm-project/pull/151534
More information about the cfe-commits
mailing list