File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -233,11 +233,22 @@ let tweak arm n strict =
233233
234234let cache = Hashtbl. create 10
235235let rec tweak_with_cache id arm n strict =
236- match Hashtbl. find_opt cache (id, arm, n, strict) with
236+ let key = (id, arm, n, strict) in
237+ match Hashtbl. find_opt cache key with
237238 | None ->
238- begin try tweak arm n strict ; raise TweakingFailed
239+ begin try
240+ tweak arm n strict ;
241+ begin match Hashtbl. find_opt cache key with
242+ | None -> ()
243+ | Some (old_res , _ , _ ) ->
244+ Hashtbl. replace cache key (
245+ old_res,
246+ (fun () -> () ),
247+ (fun () -> raise TweakingFailed ))
248+ end ;
249+ raise TweakingFailed
239250 with effect (Yield'' res ), k ->
240- Hashtbl. replace cache (id, arm, n, strict) (
251+ Hashtbl. replace cache key (
241252 res,
242253 (fun () -> try Effect.Deep. discontinue k Exit |> ignore with Exit -> () ),
243254 (fun () -> Effect.Deep. continue k () )) ;
You can’t perform that action at this time.
0 commit comments