diff options
author | Hugo Herbelin <Hugo.Herbelin@inria.fr> | 2015-02-25 07:40:11 +0100 |
---|---|---|
committer | Hugo Herbelin <Hugo.Herbelin@inria.fr> | 2015-02-25 08:21:03 +0100 |
commit | 1303e5683cb26f9dd8ed385df08d6a68b6b28fdc (patch) | |
tree | c6351e500e2e34a36019eb5dd8709701293492eb /pretyping | |
parent | 5a7a90e6fc067319e66c8021e696df98883223f0 (diff) |
Optimizing noccur_evar wrt expansion of let-ins (fix for variant of #4076).
Diffstat (limited to 'pretyping')
-rw-r--r-- | pretyping/evarsolve.ml | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pretyping/evarsolve.ml b/pretyping/evarsolve.ml index a03b50b72..d3ab4683d 100644 --- a/pretyping/evarsolve.ml +++ b/pretyping/evarsolve.ml @@ -178,7 +178,9 @@ let restrict_instance evd evk filter argsv = Filter.filter_array (Filter.compose (evar_filter evi) filter) argsv let noccur_evar env evd evk c = - let rec occur_rec k c = match kind_of_term c with + let cache = ref Int.Set.empty (* cache for let-ins *) in + let rec occur_rec k c = + match kind_of_term c with | Evar (evk',args' as ev') -> (match safe_evar_value evd ev' with | Some c -> occur_rec k c @@ -186,9 +188,10 @@ let noccur_evar env evd evk c = if Evar.equal evk evk' then raise Occur else Array.iter (occur_rec k) args') | Rel i when i > k -> + if not (Int.Set.mem (i-k) !cache) then (match pi2 (Environ.lookup_rel (i-k) env) with | None -> () - | Some b -> occur_rec k (lift i b)) + | Some b -> cache := Int.Set.add (i-k) !cache; occur_rec k (lift i b)) | Proj (p,c) -> occur_rec k (Retyping.expand_projection env evd p c []) | _ -> iter_constr_with_binders succ occur_rec k c in |