From 718f81ac774f003202b1c153b4bceaf66779f3e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Wed, 4 Jul 2018 07:56:56 -0700 Subject: [PATCH] Convert list to sequence in `Procdesc.get_siblings` Reviewed By: ddino Differential Revision: D8723595 fbshipit-source-id: a9564b7 --- infer/src/IR/Procdesc.ml | 4 ++-- infer/src/IR/Procdesc.mli | 2 +- infer/src/checkers/loop_control.ml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/infer/src/IR/Procdesc.ml b/infer/src/IR/Procdesc.ml index bc2904fb3..81600112e 100644 --- a/infer/src/IR/Procdesc.ml +++ b/infer/src/IR/Procdesc.ml @@ -101,9 +101,9 @@ module Node = struct (** Get siblings *) let get_siblings node = get_preds node - |> List.fold_left ~init:[] ~f:(fun acc parent -> + |> List.fold_left ~init:Sequence.empty ~f:(fun acc parent -> let siblings = get_succs parent |> List.filter ~f:(fun n -> not (equal node n)) in - List.rev_append siblings acc ) + Sequence.append (Sequence.of_list siblings) acc ) (** Get the node kind *) diff --git a/infer/src/IR/Procdesc.mli b/infer/src/IR/Procdesc.mli index 7ca6ad46b..6f754fd91 100644 --- a/infer/src/IR/Procdesc.mli +++ b/infer/src/IR/Procdesc.mli @@ -84,7 +84,7 @@ module Node : sig val get_preds : t -> t list (** Get the predecessor nodes of the current node *) - val get_siblings : t -> t list + val get_siblings : t -> t Sequence.t (** Get siblings of the current node *) val get_proc_name : t -> Typ.Procname.t diff --git a/infer/src/checkers/loop_control.ml b/infer/src/checkers/loop_control.ml index 64deedf78..621461842 100644 --- a/infer/src/checkers/loop_control.ml +++ b/infer/src/checkers/loop_control.ml @@ -102,7 +102,7 @@ let remove_prune_node_pairs exit_nodes guard_nodes = except_exit_nodes |> Control.GuardNodes.filter (fun node -> is_prune node - && Procdesc.Node.get_siblings node |> List.hd + && Procdesc.Node.get_siblings node |> Sequence.hd |> Option.value_map ~default:false ~f:(fun sibling -> not (Control.GuardNodes.mem sibling except_exit_nodes) ) ) |> Control.GuardNodes.union exit_nodes