aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Spiwack2014-02-24 17:17:36 +0100
committerArnaud Spiwack2014-02-24 17:17:36 +0100
commit2b6282c668a6340f982a7b9b52f9686d120257e7 (patch)
treea7952a7f907941a368c9c1506aa47309a7bb3ccf
parentd81db4a36501e6a5b5f1ba891c98409df742d0ce (diff)
TacticMatching: avoid some closure allocation in (<*>).
-rw-r--r--tactics/tacticMatching.ml14
1 files changed, 13 insertions, 1 deletions
diff --git a/tactics/tacticMatching.ml b/tactics/tacticMatching.ml
index e3a54c9bdc..e52a9011cf 100644
--- a/tactics/tacticMatching.ml
+++ b/tactics/tacticMatching.ml
@@ -182,7 +182,19 @@ module PatternMatching (E:StaticEnvironment) = struct
(** A variant of [(>>=)] when the first argument returns [unit]. *)
let (<*>) (type a) (x:unit m) (y:a m) : a m =
- x >>= fun () -> y
+ let open IStream in
+ concat_map begin fun { subst=substx; context=contextx; terms=termsx; lhs=() } ->
+ map_filter begin fun { subst=substy; context=contexty; terms=termsy; lhs=lhsy } ->
+ try
+ Some {
+ subst = subst_prod substx substy ;
+ context = context_subst_prod contextx contexty ;
+ terms = term_subst_prod termsx termsy ;
+ lhs = lhsy
+ }
+ with Not_coherent_metas -> None
+ end y
+ end x
(** Failure of the pattern-matching monad: no success. *)
let fail (type a) : a m = IStream.empty