[sledge] Optimize Trace enabled checking

Summary:
If either all or no tracing is enabled, it is not necessary to compute
the module and function names for each Trace operation to determine
whether or not it is enabled. This diff optimizes this case.

Reviewed By: ngorogiannis

Differential Revision: D27564869

fbshipit-source-id: bf766eb2f
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent df26c0f231
commit ed71043920

@ -169,16 +169,18 @@ let split_mod_fun_name s =
(mod_name, fun_name) (mod_name, fun_name)
let enabled mod_fun_name = let enabled mod_fun_name =
let mod_name, fun_name = split_mod_fun_name mod_fun_name in
let {trace_all; trace_mods_funs; _} = !config in let {trace_all; trace_mods_funs; _} = !config in
match Map.find mod_name trace_mods_funs with if Map.is_empty trace_mods_funs then trace_all
| {trace_mod; trace_funs} -> ( else
try Map.find fun_name trace_funs let mod_name, fun_name = split_mod_fun_name mod_fun_name in
with Not_found -> ( match Map.find mod_name trace_mods_funs with
match trace_mod with | {trace_mod; trace_funs} -> (
| Some mod_enabled -> mod_enabled try Map.find fun_name trace_funs
| None -> trace_all ) ) with Not_found -> (
| exception Not_found -> trace_all match trace_mod with
| Some mod_enabled -> mod_enabled
| None -> trace_all ) )
| exception Not_found -> trace_all
let kprintf mod_fun_name k fmt = let kprintf mod_fun_name k fmt =
if enabled mod_fun_name then Format.kfprintf k fs fmt if enabled mod_fun_name then Format.kfprintf k fs fmt

Loading…
Cancel
Save