[Infer][incremental] Refactoring exe_env_from_cluster

Summary: This method did previously did some unnecessary computation (call to load_cg_files) and mutable stuff.
master
Sam Blackshear 9 years ago
parent b80f74c34a
commit 41c14b249a

@ -672,20 +672,20 @@ let load_cg_files _exe_env check_changed (source_dirs : DB.source_dir list) excl
(** Create an exe_env from a cluster. *) (** Create an exe_env from a cluster. *)
let exe_env_from_cluster cluster = let exe_env_from_cluster cluster =
let _exe_env = Exe_env.create (Some (cluster_to_active_procs cluster)) in let _exe_env = Exe_env.create (Some (cluster_to_active_procs cluster)) in
let exclude_fun _ = false in let source_files, callees =
let callees = ref [] in let fold_callees pn file callees =
let source_files = (pn, file) :: callees in
let do_cluster_elem ce = let fold_cluster_elem (source_files, callees) ce =
let source_map = ce.ce_source_map in let callees = Procname.Map.fold fold_callees ce.ce_source_map callees in
let do_callee pn file = let source_files = DB.source_dir_from_source_file ce.ce_file :: source_files in
callees := (pn, file) :: !callees in source_files, callees in
Procname.Map.iter do_callee source_map; list_fold_left fold_cluster_elem ([], []) cluster in
DB.source_dir_from_source_file ce.ce_file in let sorted_files = list_sort DB.source_dir_compare source_files in
list_map do_cluster_elem cluster in list_iter (fun src_dir -> ignore(Exe_env.add_cg _exe_env src_dir)) sorted_files;
let _, exe_env = load_cg_files _exe_env false source_files exclude_fun in let exe_env = Exe_env.freeze _exe_env in
let do_callee (pn, file) = let do_callee (pn, file) =
Exe_env.add_callee exe_env file pn in Exe_env.add_callee exe_env file pn in
list_iter do_callee !callees; list_iter do_callee callees;
exe_env exe_env
(** Analyze a cluster of files *) (** Analyze a cluster of files *)

Loading…
Cancel
Save