By: Tom Sydney Kerckhove <syd@cs-syd.eu>
Compare declarations by Unique with a structural tie-break Ord Declaration was a lexical comparison of the module and occurrence names, which the profile showed to be a hot spot (every Set/Map Declaration operation pays it). Compare by the occurrence name's FastString Unique (an Int, and what its Eq already uses) first, falling back to the original structural comparison only to break Unique ties -- keeping the instance consistent with the derived Eq. (Comparing the *module* by Unique was tried and was slower: a Module's Unique is not a cached field.) Because Set Declaration is now ordered by run-dependent Uniques, break ties in the output sort with the declaration's display name so the reported order stays deterministic. ~15% less mutator time on a large real corpus, output unchanged.