hintonda added a comment. Could you use a SetVector or SmallSetVector instead of a DenseSet for DIImportedEntities? It's equivalent to what you've proposed, but since it knows when it inserts a new one, maintaining the vector is much cheaper. http://reviews.llvm.org/D17884