Join GitHub today
[patch] Bad typing performances of big variant type declaration #5944
Original bug ID: 5944
The typing complexity of variant type declaration like:
type t = X1 | X2 | X3 | [...] | X32768
is very bad.
This kind of code pattern is somtime usefull, in particular in OCaPIC low level libraries, and it can be fixed by the small and simple attached patch.
Steps to reproduce
Insert this kind of type declaration in a x.mli file and run:
time ocamlopt x.mli
The culprit function is check_constraints defined in typing/typedecl.ml.
With this patch, the time needed to compile a variant definition with 32768 constant constructors go down from 29s to 0.39s (on my computer).