Fix List.drop

Reviewed By: ngorogiannis

Differential Revision: D8162217

fbshipit-source-id: 69a6557
master
Mehdi Bouaziz 7 years ago committed by Facebook Github Bot
parent 7a68dde647
commit 1d62441918

@ -309,11 +309,9 @@ struct
let exceptional_succs _ _ = (* not used *) assert false
let list_mem_nth list index = List.drop list index |> List.is_empty |> not
let succs cfg (node, index) =
let succ_index = index + 1 in
if list_mem_nth (Base.instrs node) succ_index then [(node, succ_index)]
if IList.mem_nth (Base.instrs node) succ_index then [(node, succ_index)]
else List.map ~f:first_of_node (Base.succs cfg node)

@ -672,7 +672,7 @@ let execute_scan_function skip_n_arguments ({Builtin.args; ret_id_typ} as call_a
match args with
| _ when List.length args >= skip_n_arguments ->
let varargs = ref args in
varargs := List.drop !varargs skip_n_arguments ;
varargs := IList.drop !varargs skip_n_arguments ;
SymExec.unknown_or_scan_call ~is_scan:true ~reason:"execute scan function" (snd ret_id_typ)
Annot.Item.empty {call_args with args= !varargs}
| _ ->

@ -311,7 +311,7 @@ let component_with_multiple_factory_methods_advice context an =
document which are optional."
; doc_url= None
; loc= CFrontend_checkers.location_from_decl context meth_decl } )
(List.drop factory_methods 1)
(IList.drop factory_methods 1)
| _ ->
assert false
in

@ -401,7 +401,7 @@ let typecheck_instr tenv ext calls_this checks (node: Procdesc.Node.t) idenv get
0
in
let n = drop_n_args proc_attributes.ProcAttributes.formals in
let visible_params = List.drop params n in
let visible_params = IList.drop params n in
(* Drop the trailing hidden parameter if the constructor is synthetic. *)
if proc_attributes.ProcAttributes.is_synthetic_method then
List.take visible_params (List.length visible_params - 1)

@ -137,3 +137,11 @@ let merge_dedup l1 l2 ~compare =
else loop (h2 :: acc) l1 t2
in
loop [] l1 l2
(* Remove when Base.List.drop perf is fixed *)
let rec drop list index =
match list with _ :: tl when index > 0 -> drop tl (index - 1) | _ -> list
let mem_nth list index = drop list index |> List.is_empty |> not

@ -35,3 +35,9 @@ val append_no_duplicates : cmp:('a -> 'a -> int) -> ('a list -> 'a list -> 'a li
duplicates. *)
val merge_dedup : 'a list -> 'a list -> compare:('a -> 'a -> int) -> 'a list
val drop : 'a list -> int -> 'a list
(** [drop l n] returns [l] without the first [n] elements, or the empty list if [n > length l]. *)
val mem_nth : 'a list -> int -> bool
(** [mem_nth l n] returns whether the list [l] contains a [n]th element. *)

Loading…
Cancel
Save