From a10bff1e533da2ddebcbcde7a18943f0d4c804c3 Mon Sep 17 00:00:00 2001 From: Gabriel Scherer Date: Wed, 3 Jan 2018 22:43:42 +0100 Subject: [PATCH] Parmatch.matrix_stable_vars: optimize the all-negative case --- typing/parmatch.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/typing/parmatch.ml b/typing/parmatch.ml index e14706696b81..b9dcf4a259bc 100644 --- a/typing/parmatch.ml +++ b/typing/parmatch.ml @@ -2366,6 +2366,11 @@ let rec matrix_stable_vars m = match m with (* The stable variables are those stable at any position *) Vars (List.fold_left IdSet.union IdSet.empty stables_in_varsets) end + | m when List.for_all (function Negative _ -> true | Positive _ -> false) m -> + (* optimization: if m has many negative cases and few positive cases + (a small guarded clause after a long list of clauses), many sub-matrices + may have no positives at all; quit early in this case *) + All | m -> let m = simplify_first_amb_col m in if not (all_coherent (first_column m))