Skip to content

Commit

Permalink
Xapi_events: replace List.any+map with List.exists
Browse files Browse the repository at this point in the history
Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Apr 21, 2024
1 parent 4b298e3 commit 3248809
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ocaml/xapi/xapi_event.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ module Subscription = struct
(Api_errors.event_subscription_parse_failure, [x])
)

let any = List.fold_left (fun acc x -> acc || x) false

(** [table_matches subs tbl]: true if at least one subscription from [subs] would select some events from [tbl] *)
let table_matches subs tbl =
let tbl = String.lowercase_ascii tbl in
Expand All @@ -86,7 +84,7 @@ module Subscription = struct
| Object (x, _) ->
x = tbl
in
any (List.map matches subs)
List.exists matches subs

(** [event_matches subs ev]: true if at least one subscription from [subs] selects for specified class and object *)
let object_matches subs ty _ref =
Expand All @@ -99,7 +97,7 @@ module Subscription = struct
| Object (x, y) ->
x = tbl && y = _ref
in
any (List.map matches subs)
List.exists matches subs

(** [event_matches subs ev]: true if at least one subscription from [subs] selects for event [ev] *)
let event_matches subs ev = object_matches subs ev.ty ev.reference
Expand Down

0 comments on commit 3248809

Please sign in to comment.