Avoid wasteful allocations in mkTyConAppCo
Ticket: #27648 (closed)
The idiom traverse isReflCo_maybe followed by map fst used in GHC.Core.Coercion.mkTyConAppCo was allocating a lot of waste.
This MR uses GHC.Data.Unboxed.traverseMaybeUB to avoid all these unnecessary intermediate allocations.
In a quick microbenchmark for mkTyConAppCo, this change resulted in:
- refl case (all argument coercions are reflexive):
- -60% runtime
- -80% allocations
- non-refl case:
- from 0% to -12% runtime (depending on which argument is non-refl)
- from 0% to -70% allocations ( -- '' -- )