diff --git a/infer/src/checkers/Source.ml b/infer/src/checkers/Source.ml index 35bce0d21..ac401d039 100644 --- a/infer/src/checkers/Source.ml +++ b/infer/src/checkers/Source.ml @@ -33,7 +33,8 @@ module Dummy = struct let pp _ () = () - let is_footprint _ = assert false + let is_footprint _ = false + let make_footprint _ _ = assert false let get_footprint_access_path _ = assert false let get _ = None diff --git a/infer/src/checkers/Trace.ml b/infer/src/checkers/Trace.ml index 55046a656..eff3ad02b 100644 --- a/infer/src/checkers/Trace.ml +++ b/infer/src/checkers/Trace.ml @@ -165,14 +165,22 @@ module Make (Spec : Spec) = struct Sources.is_empty t.sources let get_reports t = - if Sinks.is_empty t.sinks - then [] + if Sinks.is_empty t.sinks || Sources.is_empty t.sources + then + [] else - let report_one source sink acc = - if Spec.should_report source sink - then (source, sink, t.passthroughs) :: acc - else acc in - Sources.fold (fun source acc -> Sinks.fold (report_one source) t.sinks acc) t.sources [] + (* written to avoid closure allocations in hot code. change with caution. *) + let report_source source sinks acc0 = + let report_one sink acc = + if Spec.should_report source sink + then (source, sink, t.passthroughs) :: acc + else acc in + Sinks.fold report_one sinks acc0 in + let report_sources source acc = + if Source.is_footprint source + then acc + else report_source source t.sinks acc in + Sources.fold report_sources t.sources [] let pp_path cur_pname fmt (cur_passthroughs, sources_passthroughs, sinks_passthroughs) = let pp_passthroughs fmt passthroughs = diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index 059b39f89..7843937ab 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -45,7 +45,7 @@ module MockTrace = Trace.Make(struct then Some site else None - let is_footprint _ = assert false + let is_footprint _ = false let make_footprint _ = assert false let get_footprint_access_path _ = assert false end