Skip to content

Commit f0c6237

Browse files
authored
Compiler: rely more on the cache to compute function sizes (#2014)
1 parent 7306b7f commit f0c6237

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/lib/inline.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,13 @@ let rec block_size ~recurse ~context { branch; body; _ } =
242242
~f:(fun n i ->
243243
match i with
244244
| Event _ -> n
245-
| Let (_, Closure (_, (pc, _), _)) ->
246-
if recurse then size ~recurse ~context pc + n + 1 else n + 1
245+
| Let (f, Closure (_, (pc, _), _)) ->
246+
if recurse
247+
then
248+
match Var.Map.find f context.env with
249+
| exception Not_found -> size ~recurse ~context pc + n + 1
250+
| info -> cache ~info info.full_size (size ~recurse:true ~context) + n + 1
251+
else n + 1
247252
| _ -> n + 1)
248253
~init:
249254
(match branch with

0 commit comments

Comments
 (0)