Skip to content

Commit

Permalink
CP-52225 - oxenstored: Move to stdlib String functions instead of Stdext
Browse files Browse the repository at this point in the history
String.fold_left and String.starts_with are available since OCaml 4.13

Signed-off-by: Andrii Sultanov <[email protected]>
  • Loading branch information
last-genius committed Nov 13, 2024
1 parent 172fcad commit 5b30db4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion oxenstored/connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ let get_children_watches con path =
let path = path ^ "/" in
List.concat
(Hashtbl.fold
(fun p w l -> if String.startswith path p then w :: l else l)
(fun p w l -> if String.starts_with ~prefix:path p then w :: l else l)
con.watches []
)

Expand Down
4 changes: 2 additions & 2 deletions oxenstored/logging.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let log_destination_of_string s =
let prefix = "syslog:" in
let len_prefix = String.length prefix in
let len = String.length s in
if String.startswith prefix s then
if String.starts_with ~prefix s then
Syslog
(Syslog.facility_of_string (String.sub s len_prefix (len - len_prefix)))
else
Expand Down Expand Up @@ -433,7 +433,7 @@ let live_update () =
let xb_answer ~tid ~con ~ty data =
let print, level =
match ty with
| Xenbus.Xb.Op.Error when String.startswith "ENOENT" data ->
| Xenbus.Xb.Op.Error when String.starts_with ~prefix:"ENOENT" data ->
(!access_log_read_ops, Warn)
| Xenbus.Xb.Op.Error ->
(true, Warn)
Expand Down
12 changes: 0 additions & 12 deletions oxenstored/stdext.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ module String = struct
let a = String.sub s 0 i
and b = String.sub s (i + 1) (String.length s - i - 1) in
a :: split ~limit:nlimit c b

let fold_left f accu string =
let accu = ref accu in
for i = 0 to length string - 1 do
accu := f !accu string.[i]
done ;
!accu

(** True if string 'x' starts with prefix 'prefix' *)
let startswith prefix x =
let x_l = String.length x and prefix_l = String.length prefix in
prefix_l <= x_l && String.sub x 0 prefix_l = prefix
end

module Unixext = struct
Expand Down

0 comments on commit 5b30db4

Please sign in to comment.