Fix quadratic behavior of prepareAlts

Authored by niteria on Jan 12 2018, 8:02 PM.


Fix quadratic behavior of prepareAlts

This code is quadratic and a simple test case I used
managed to tickle it.

The example (same one as Trac #14667) looks like this:

module A10000 where

 data A = A
   | A00001
   | A00002
   | A10000

 f :: A -> Int
 f A00001 = 19900001
 f A00002 = 19900002
 f A10000 = 19910000

Applied on top of a fix for Trac #14667, it gives a 30% compile time

Test Plan: ./validate

Reviewers: simonpj, bgamari

Subscribers: rwbarton, thomie, simonmar, carter

Differential Revision: