Skip to content

Commit f056bfa

Browse files
arthaudfacebook-github-bot
authored andcommitted
Use transform Filter instead of partition ByFilter
Summary: Now that we have a `transform Filter`, let's use it instead of using `partition ByFilter |> ~f:(fun x -> if cond then None else Some false) |> (fun map -> Map.Poly.find map false)`. That is shorter and more efficient. Reviewed By: dkgi Differential Revision: D30758495 fbshipit-source-id: 4060ccce64119e8728c877cb9742d03f1f51d8e5
1 parent e4feee6 commit f056bfa

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

source/interprocedural_analyses/taint/domains.ml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,9 @@ module MakeTaintTree (Taint : TAINT_DOMAIN) () = struct
558558
let apply_call location ~callees ~port taint_tree =
559559
let transform_path (path, tip) =
560560
let tip =
561-
Taint.partition
562-
Taint.kind
563-
ByFilter
564-
~f:(fun kind -> if Taint.ignore_kind_at_call kind then None else Some false)
565-
tip
566-
|> (fun map -> Map.Poly.find map false)
567-
|> function
568-
| None -> Taint.bottom
569-
| Some taint -> Taint.apply_call location ~callees ~port ~path ~element:taint
561+
tip
562+
|> Taint.transform Taint.kind Filter ~f:(fun kind -> not (Taint.ignore_kind_at_call kind))
563+
|> fun taint -> Taint.apply_call location ~callees ~port ~path ~element:taint
570564
in
571565
path, tip
572566
in
@@ -619,11 +613,9 @@ module MakeTaintTree (Taint : TAINT_DOMAIN) () = struct
619613

620614

621615
let filter_by_kind ~kind taint_tree =
622-
collapse ~transform:Fn.id taint_tree
623-
|> Taint.partition Taint.kind ByFilter ~f:(fun candidate ->
624-
if Taint.equal_kind kind candidate then Some true else None)
625-
|> (fun map -> Map.Poly.find map true)
626-
|> Option.value ~default:Taint.bottom
616+
taint_tree
617+
|> transform Taint.kind Filter ~f:(Taint.equal_kind kind)
618+
|> collapse ~transform:Fn.id
627619

628620

629621
let get_all_features taint_tree =

0 commit comments

Comments
 (0)