From be4f29c6d62ecef7c8736c1cd154616d3ef5292c Mon Sep 17 00:00:00 2001 From: letouzey Date: Mon, 18 Feb 2013 20:39:59 +0000 Subject: 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 --- kernel/mod_subst.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'kernel/mod_subst.ml') 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 -- cgit v1.2.3