[minor] Use List.is_empty instead of List.length equal to 0

Reviewed By: mbouaziz, jvillard

Differential Revision: D7909827

fbshipit-source-id: 4ea8b90
master
Daiva Naudziuniene 7 years ago committed by Facebook Github Bot
parent 5e6c859922
commit 28b696881c

@ -14,7 +14,7 @@ open! IStd
module F = Format
let list_to_string list =
if Int.equal (List.length list) 0 then "( sub )"
if List.is_empty list then "( sub )"
else "- {" ^ String.concat ~sep:", " (List.map ~f:Typ.Name.name list) ^ "}"

@ -1103,7 +1103,7 @@ let pp_cfgnodelabel pdesc fmt (n: Procdesc.Node.t) =
let byvals = attributes.ProcAttributes.by_vals in
Format.fprintf fmt "Start %s\\nFormals: %a\\nLocals: %a" pname_string (pp_etlist byvals)
(Procdesc.get_formals pdesc) pp_local_list (Procdesc.get_locals pdesc) ;
if List.length (Procdesc.get_captured pdesc) <> 0 then
if not (List.is_empty (Procdesc.get_captured pdesc)) then
Format.fprintf fmt "\\nCaptured: %a" pp_var_list (Procdesc.get_captured pdesc) ;
let method_annotation = attributes.ProcAttributes.method_annotation in
if not (Annot.Method.is_empty method_annotation) then

@ -1390,7 +1390,7 @@ let exe_call_postprocess tenv ret_id trace_call callee_pname callee_attrs loc re
let should_add_ret_attr _ =
let is_likely_getter = function
| Typ.Procname.Java pn_java ->
Int.equal (List.length (Typ.Procname.Java.get_parameters pn_java)) 0
List.is_empty (Typ.Procname.Java.get_parameters pn_java)
| _ ->
false
in

@ -223,7 +223,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
let rhs_base, al = AccessExpression.to_access_path rhs_access_expr in
let uninit_vars' = D.remove lhs_ap astate.uninit_vars in
let uninit_vars =
if Int.equal (List.length apl) 0 then
if List.is_empty apl then
(* if we assign to the root of a struct then we need to remove all the fields *)
remove_all_fields tenv (lhs_var, lhs_typ) uninit_vars'
else uninit_vars'

@ -552,7 +552,7 @@ let get_objc_property_accessor tenv ms =
(** Creates a procedure description. *)
let create_local_procdesc ?(set_objc_accessor_attr= false) trans_unit_ctx cfg tenv ms fbody
captured =
let defined = not (Int.equal (List.length fbody) 0) in
let defined = not (List.is_empty fbody) in
let proc_name = ms.CMethodSignature.name in
let pname = Typ.Procname.to_string proc_name in
let attributes = sil_func_attributes_of_attributes ms.CMethodSignature.attributes in

@ -2152,7 +2152,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
| None ->
create_var_exp_tmp_var trans_state expr_info "SIL_init_list__"
in
if Int.equal (List.length stmts) 0 then
if List.is_empty stmts then
(* perform zero initialization of a primitive type, record types will have
ImplicitValueInitExpr nodes *)
let exps =
@ -2298,7 +2298,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
; initd_exps= res_trans_tmp.initd_exps @ res_trans_vd.initd_exps }
, Some leaf_nodes )
| _ :: var_decls' ->
(* Here we can get also record declarations or typedef declarations, which are dealt with somewhere else.
(* Here we can get also record declarations or typedef declarations, which are dealt with somewhere else.
We just handle the variables here. *)
collect_all_decl_inner trans_state var_decls'
in

@ -77,7 +77,7 @@ let get_exit_location source_file bytecode =
let retrieve_fieldname fieldname =
try
let subs = Str.split (Str.regexp (Str.quote ".")) (Typ.Fieldname.to_string fieldname) in
if Int.equal (List.length subs) 0 then assert false else List.last_exn subs
List.last_exn subs
with _ -> assert false

Loading…
Cancel
Save