Skip to content

Commit

Permalink
Further tweak to reduce stack usage
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Oct 14, 2024
1 parent b4ea53d commit 2c5c800
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/picos/picos.ocaml5.ml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ module Computation = struct
| y -> try_return t y
| exception exn -> try_capture_raised exn t

let capture t fn x = try_capture t fn x |> ignore
let capture t fn x =
(* Intentionally manually inlined [try_capture] to minimize stack usage *)
(match fn x with
| y -> try_return t y
| exception exn -> try_capture_raised exn t)
|> ignore

let[@inline never] raise (Canceled { exn; bt; _ } : (_, [ `Canceled ]) st) =
Printexc.raise_with_backtrace exn bt
Expand Down

0 comments on commit 2c5c800

Please sign in to comment.