Skip to content

Commit 2c5c800

Browse files
committed
Further tweak to reduce stack usage
1 parent b4ea53d commit 2c5c800

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/picos/picos.ocaml5.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,12 @@ module Computation = struct
341341
| y -> try_return t y
342342
| exception exn -> try_capture_raised exn t
343343

344-
let capture t fn x = try_capture t fn x |> ignore
344+
let capture t fn x =
345+
(* Intentionally manually inlined [try_capture] to minimize stack usage *)
346+
(match fn x with
347+
| y -> try_return t y
348+
| exception exn -> try_capture_raised exn t)
349+
|> ignore
345350

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

0 commit comments

Comments
 (0)