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