Add a cache that protects mergefunc's internals from more surprises in DenseSet.