Skip to content

Commit f60188f

Browse files
arthaudfacebook-github-bot
authored andcommitted
Filter by attach to leaves before collapsing
Summary: The function that computes attach to features is pretty slow since it collapses all the taint before filtering by attach to kinds. Let's filter before collapsing. Reviewed By: dkgi Differential Revision: D30758356 fbshipit-source-id: c72fadb219b8c61076900d92f8bd9f9651a34187
1 parent bae767c commit f60188f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

source/interprocedural_analyses/taint/domains.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
open Core
99
open Ast
10-
open Pyre
1110

1211
module type SET_ARG = sig
1312
include Abstract.SetDomain.ELEMENT
@@ -709,12 +708,9 @@ module MakeTaintEnvironment (Taint : TAINT_DOMAIN) () = struct
709708
let extract_features_to_attach ~root ~attach_to_leaf taint =
710709
let gather_features to_add features = Features.SimpleSet.add_set features ~to_add in
711710
read ~root ~path:[] taint
711+
|> Tree.transform Taint.leaf Filter ~f:(Taint.equal_leaf attach_to_leaf)
712712
|> Tree.collapse ~transform:Fn.id
713-
|> Taint.partition Taint.leaf ByFilter ~f:(fun leaf ->
714-
if Taint.equal_leaf attach_to_leaf leaf then Some true else None)
715-
|> (fun map -> Map.Poly.find map true)
716-
>>| Taint.fold Taint.simple_feature_self ~f:gather_features ~init:Features.SimpleSet.bottom
717-
|> Option.value ~default:Features.SimpleSet.bottom
713+
|> Taint.fold Taint.simple_feature_self ~f:gather_features ~init:Features.SimpleSet.bottom
718714
end
719715
720716
module ForwardState = MakeTaintEnvironment (ForwardTaint) ()

0 commit comments

Comments
 (0)