fix day 12 performance regerssion

caused by a change to Grid.at_e that would eagerly format an exception
string even if the function never throws an exception.
This commit is contained in:
ryan manseau 2024-01-08 12:48:55 -08:00
parent d203c9a520
commit 950f2860df

View File

@ -27,8 +27,9 @@ let at grid point =
;;
let at_e (grid : 'a t) (point : Vec2.t) =
Option.get_exn_or (Format.sprintf "point %a out of bounds!" Vec2.pp point)
@@ at grid point
match at grid point with
| Some point -> point
| None -> failwith @@ Format.sprintf "point %a out of bounds!" Vec2.pp point
;;
let set_e grid point item =