From 6611bee736781e81886f877acf4708357e93f6e5 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Tue, 3 Jul 2018 05:30:20 -0700 Subject: [PATCH] [prop] memory usage improvement Summary: This was showing up during memory profiling with statistical-memprof. The surrounding code shows that we are trying not to allocate if nothing changes, but the `List.map` in the middle would defeat that. Reviewed By: ngorogiannis Differential Revision: D8661763 fbshipit-source-id: d44f7a7 --- infer/src/biabduction/Prop.ml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/infer/src/biabduction/Prop.ml b/infer/src/biabduction/Prop.ml index adfd98ed2..2c265f6dc 100644 --- a/infer/src/biabduction/Prop.ml +++ b/infer/src/biabduction/Prop.ml @@ -1412,7 +1412,7 @@ module Normalize = struct let find_captured_variable_in_the_heap captured' hpred = match hpred with | Hpointsto (Exp.Lvar var, Eexp (Exp.Var id, _), _) -> - List.map + IList.map_changed ~equal:phys_equal ~f:(fun ((e_captured, var_captured, t) as captured_item) -> match e_captured with | Exp.Var id_captured -> @@ -1444,7 +1444,11 @@ module Normalize = struct if phys_equal exp new_exp then se else Eexp (new_exp, inst) | Estruct (fields, inst) -> let new_fields = - List.map ~f:(fun (field, se) -> (field, process_closures_in_se se)) fields + IList.map_changed ~equal:phys_equal + ~f:(fun ((field, se) as fse) -> + let se' = process_closures_in_se se in + if phys_equal se se' then fse else (field, se') ) + fields in if phys_equal fields new_fields then se else Estruct (new_fields, inst) | _ ->