Summary: Instead of looking up each proc name in models/, pre-compute the list of models and do lookups there instead of in the filesystem. Reviewed By: ngorogiannis Differential Revision: D16603148 fbshipit-source-id: 5eb534a14master
parent
50c98db391
commit
e1d7ce9628
@ -0,0 +1,33 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
let scan_models () =
|
||||
let rec next_entry index dir =
|
||||
match Unix.readdir_opt dir with
|
||||
| None ->
|
||||
Unix.closedir dir ; index
|
||||
| Some entry -> (
|
||||
match String.chop_suffix entry ~suffix:Config.specs_files_suffix with
|
||||
| Some file_proc_name ->
|
||||
next_entry (String.Set.add index file_proc_name) dir
|
||||
| None ->
|
||||
next_entry index dir )
|
||||
in
|
||||
match Unix.opendir Config.biabduction_models_dir with
|
||||
| dir ->
|
||||
next_entry String.Set.empty dir
|
||||
| exception Unix.Unix_error ((ENOTDIR | ENOENT), _, _) ->
|
||||
String.Set.empty
|
||||
|
||||
|
||||
let models_index =
|
||||
lazy (if not Config.biabduction_models_mode then scan_models () else String.Set.empty)
|
||||
|
||||
|
||||
let mem proc_name = String.Set.mem (Lazy.force models_index) (Procname.to_filename proc_name)
|
@ -0,0 +1,11 @@
|
||||
(*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*)
|
||||
|
||||
open! IStd
|
||||
|
||||
val mem : Procname.t -> bool
|
||||
(** Check if a summary for a given procedure exists in the models directory *)
|
Loading…
Reference in new issue