Skip to content

Commit 81fb386

Browse files
committed
xapi-stdext-std: Delete unused xstringext methods
Signed-off-by: Pau Ruiz Safont <pau.ruizsafont@cloud.com> Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent 8ae7840 commit 81fb386

3 files changed

Lines changed: 1 addition & 77 deletions

File tree

ocaml/libs/xapi-stdext/lib/xapi-stdext-std/xstringext.ml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414
module String = struct
15-
let of_char c = String.make 1 c
16-
17-
let rev_map f string =
18-
let n = String.length string in
19-
String.init n (fun i -> f string.[n - i - 1])
20-
21-
let rev_iter f string =
22-
for i = String.length string - 1 downto 0 do
23-
f string.[i]
24-
done
25-
26-
let fold_left f accu string =
27-
let accu = ref accu in
28-
for i = 0 to String.length string - 1 do
29-
accu := f !accu string.[i]
30-
done ;
31-
!accu
32-
33-
let fold_right f string accu =
34-
let accu = ref accu in
35-
for i = String.length string - 1 downto 0 do
36-
accu := f string.[i] !accu
37-
done ;
38-
!accu
39-
4015
(** Returns true for whitespace characters, false otherwise *)
4116
let isspace = function ' ' | '\n' | '\r' | '\t' -> true | _ -> false
4217

@@ -174,8 +149,4 @@ module String = struct
174149
String.escaped s
175150
| Some rules ->
176151
map_unlikely s (fun c -> List.assoc_opt c rules)
177-
178-
let sub_before c s = String.sub s 0 (String.index s c)
179-
180-
let sub_after c s = sub_to_end s (String.index s c + 1)
181152
end

ocaml/libs/xapi-stdext/lib/xapi-stdext-std/xstringext.mli

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414
module String : sig
15-
val of_char : char -> string
16-
17-
val rev_map : (char -> char) -> string -> string
18-
(** Map a string to a string, applying the given function in reverse
19-
order. *)
20-
21-
val rev_iter : (char -> unit) -> string -> unit
22-
(** Iterate over the characters in a string in reverse order. *)
23-
24-
val fold_left : ('a -> char -> 'a) -> 'a -> string -> 'a
25-
(** Fold over the characters in a string. *)
26-
27-
val fold_right : (char -> 'a -> 'a) -> string -> 'a -> 'a
28-
(** Iterate over the characters in a string in reverse order. *)
29-
3015
val isspace : char -> bool
3116
(** True if the character is whitespace *)
3217

@@ -49,9 +34,6 @@ module String : sig
4934
val has_substr : string -> string -> bool
5035
(** True if sub is a substr of str *)
5136

52-
val find_all : string -> string -> int list
53-
(** find all occurences of needle in haystack and return all their respective index *)
54-
5537
val replace : string -> string -> string -> string
5638
(** replace all [f] substring in [s] by [t] *)
5739

@@ -63,10 +45,4 @@ module String : sig
6345

6446
val sub_to_end : string -> int -> string
6547
(** a substring from the specified position to the end of the string *)
66-
67-
val sub_before : char -> string -> string
68-
(** a substring from the start of the string to the first occurrence of a given character, excluding the character *)
69-
70-
val sub_after : char -> string -> string
71-
(** a substring from the first occurrence of a given character to the end of the string, excluding the character *)
7248
end

ocaml/libs/xapi-stdext/lib/xapi-stdext-std/xstringext_test.ml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@ let test_list tested_f (name, case, expected) =
2727
in
2828
(name, `Quick, check)
2929

30-
let test_rev_map =
31-
let spec_rev = [("", ""); ("foo bar", "rab oof")] in
32-
let spec_func = [("id", Fun.id); ("uppercase_ascii", Char.uppercase_ascii)] in
33-
let test (f_name, f) (case, expected) =
34-
let expected = String.map f expected in
35-
let name =
36-
Printf.sprintf {|"%s" produces "%s" (%s)|} case expected f_name
37-
in
38-
test_string (XString.rev_map f) (name, case, expected)
39-
in
40-
let tests =
41-
(* Generate the product of the two lists to generate the tests *)
42-
List.concat_map (fun func -> List.map (test func) spec_rev) spec_func
43-
in
44-
("rev_map", tests)
45-
4630
let test_split =
4731
let test limit (splitter, splitted, expected) =
4832
let split = XString.split ~limit in
@@ -168,11 +152,4 @@ let test_escaped =
168152

169153
let () =
170154
Alcotest.run "Xstringext"
171-
[
172-
test_rev_map
173-
; test_split
174-
; test_split_f
175-
; test_has_substr
176-
; test_rtrim
177-
; test_escaped
178-
]
155+
[test_split; test_split_f; test_has_substr; test_rtrim; test_escaped]

0 commit comments

Comments
 (0)