aboutsummaryrefslogtreecommitdiff
path: root/pretyping/evd.ml
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2014-08-09 13:18:25 +0200
committerPierre-Marie Pédrot2014-08-09 13:19:06 +0200
commiteec72af81a84f7b56b04027693684eebe139a607 (patch)
tree795942dc666a904a716bfabe70fe3eeb5d1460ef /pretyping/evd.ml
parentff884c172697c1452db535cdbd6babceb556c428 (diff)
Tentative performance fix for Evd.merge_uctx.
The levels added by the context are in general much fewer than the size of the evarmap, so it is better to add them to the latter rather than doing it the other way around.
Diffstat (limited to 'pretyping/evd.ml')
-rw-r--r--pretyping/evd.ml7
1 files changed, 5 insertions, 2 deletions
diff --git a/pretyping/evd.ml b/pretyping/evd.ml
index cd02d7228a..c60fb29586 100644
--- a/pretyping/evd.ml
+++ b/pretyping/evd.ml
@@ -960,8 +960,11 @@ let merge_uctx rigid uctx ctx' =
| UnivRigid -> uctx
| UnivFlexible b ->
let levels = Univ.ContextSet.levels ctx' in
- let uvars' = Univ.LMap.bind (fun _ -> None) levels in
- let uvars' = Univ.LMap.fold Univ.LMap.add uctx.uctx_univ_variables uvars' in
+ let fold u accu =
+ if Univ.LMap.mem u accu then accu
+ else Univ.LMap.add u None accu
+ in
+ let uvars' = Univ.LSet.fold fold levels uctx.uctx_univ_variables in
if b then
{ uctx with uctx_univ_variables = uvars';
uctx_univ_algebraic = Univ.LSet.union uctx.uctx_univ_algebraic levels }