diff options
author | letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2013-02-18 20:39:59 +0000 |
---|---|---|
committer | letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2013-02-18 20:39:59 +0000 |
commit | be4f29c6d62ecef7c8736c1cd154616d3ef5292c (patch) | |
tree | 22ee08cbfd5d5e5a0858762a82433de9c1abc553 /kernel/mod_subst.ml | |
parent | 4c1ccb9e2a4b219ac5180115bc4267e1b059cdd1 (diff) |
Mod_subst: improve sharing during kn substitutions
When user and canonical parts are physically equal, let's avoid
computing both their substitutions : this is a waste of time and
also potentially of memory sharing. For instance two identical
sub-calls to subst_mp0 may produce answers that are = but not ==.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16216 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'kernel/mod_subst.ml')
-rw-r--r-- | kernel/mod_subst.ml | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kernel/mod_subst.ml b/kernel/mod_subst.ml index a43c5b274..817716c2d 100644 --- a/kernel/mod_subst.ml +++ b/kernel/mod_subst.ml @@ -224,8 +224,10 @@ let constant_of_delta_with_inline resolve con = let kn1,kn2 = canonical_con con,user_con con in try find_inline_of_delta kn2 resolve with Not_found -> - try find_inline_of_delta kn1 resolve - with Not_found -> None + if kn1 == kn2 then None + else + try find_inline_of_delta kn1 resolve + with Not_found -> None let subst_mp0 sub mp = (* 's like subst *) let rec aux mp = @@ -273,7 +275,9 @@ type sideconstantsubst = | Canonical let gen_subst_mp f sub mp1 mp2 = - match subst_mp0 sub mp1, subst_mp0 sub mp2 with + let o1 = subst_mp0 sub mp1 in + let o2 = if mp1 == mp2 then o1 else subst_mp0 sub mp2 in + match o1, o2 with | None, None -> raise No_subst | Some (mp',resolve), None -> User, (f mp' mp2), resolve | None, Some (mp',resolve) -> Canonical, (f mp1 mp'), resolve |