Skip to content

Commit 7064d59

Browse files
author
Andrii Sultanov
committed
CP-52225 - oxenstored: Move to stdlib String functions instead of Stdext
String.fold_left and String.starts_with are available since OCaml 4.13 Signed-off-by: Andrii Sultanov <[email protected]>
1 parent def7ca2 commit 7064d59

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

oxenstored/connection.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ let get_children_watches con path =
317317
let path = path ^ "/" in
318318
List.concat
319319
(Hashtbl.fold
320-
(fun p w l -> if String.startswith path p then w :: l else l)
320+
(fun p w l -> if String.starts_with ~prefix:path p then w :: l else l)
321321
con.watches []
322322
)
323323

oxenstored/logging.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let log_destination_of_string s =
2525
let prefix = "syslog:" in
2626
let len_prefix = String.length prefix in
2727
let len = String.length s in
28-
if String.startswith prefix s then
28+
if String.starts_with ~prefix s then
2929
Syslog
3030
(Syslog.facility_of_string (String.sub s len_prefix (len - len_prefix)))
3131
else
@@ -435,7 +435,7 @@ let live_update () =
435435
let xb_answer ~tid ~con ~ty data =
436436
let print, level =
437437
match ty with
438-
| Xenbus.Xb.Op.Error when String.startswith "ENOENT" data ->
438+
| Xenbus.Xb.Op.Error when String.starts_with ~prefix:"ENOENT" data ->
439439
(!access_log_read_ops, Warn)
440440
| Xenbus.Xb.Op.Error ->
441441
(true, Warn)

oxenstored/stdext.ml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,6 @@ module String = struct
8282
let a = String.sub s 0 i
8383
and b = String.sub s (i + 1) (String.length s - i - 1) in
8484
a :: split ~limit:nlimit c b
85-
86-
let fold_left f accu string =
87-
let accu = ref accu in
88-
for i = 0 to length string - 1 do
89-
accu := f !accu string.[i]
90-
done ;
91-
!accu
92-
93-
(** True if string 'x' starts with prefix 'prefix' *)
94-
let startswith prefix x =
95-
let x_l = String.length x and prefix_l = String.length prefix in
96-
prefix_l <= x_l && String.sub x 0 prefix_l = prefix
9785
end
9886

9987
module Unixext = struct

0 commit comments

Comments
 (0)