Skip to content

Commit dd040a9

Browse files
committed
xapi-stdext-std: replace String.filter_chars with Astring.filter
The former didn't have any tests and the performance is unknown Signed-off-by: Pau Ruiz Safont <pau.ruizsafont@cloud.com> Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent e41ce96 commit dd040a9

6 files changed

Lines changed: 3 additions & 23 deletions

File tree

ocaml/libs/tgroup/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(name tgroup)
33
(modules tgroup)
44
(public_name tgroup)
5-
(libraries unix xapi-log xapi-stdext-unix xapi-stdext-std))
5+
(libraries astring unix xapi-log xapi-stdext-unix))
66

77
(test
88
(name test_tgroup)

ocaml/libs/tgroup/tgroup.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ module Group = struct
7070
| _ ->
7171
false
7272

73-
let sanitize s =
74-
Xapi_stdext_std.Xstringext.String.filter_chars s is_alphanum
73+
let sanitize s = Astring.String.filter is_alphanum s
7574

7675
let make ?user_agent subject_sid =
7776
let user_agent =

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,6 @@ module String = struct
9898
) else
9999
s
100100

101-
let filter_chars s valid =
102-
let badchars = ref false in
103-
let buf = Buffer.create 0 in
104-
for i = 0 to String.length s - 1 do
105-
if !badchars then (
106-
if valid s.[i] then
107-
Buffer.add_char buf s.[i]
108-
) else if not (valid s.[i]) then (
109-
Buffer.add_substring buf s 0 i ;
110-
badchars := true
111-
)
112-
done ;
113-
if !badchars then Buffer.contents buf else s
114-
115101
let map_unlikely s f =
116102
let changed = ref false in
117103
let m = ref 0 in

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ module String : sig
3434
val replace : string -> string -> string -> string
3535
(** replace all [f] substring in [s] by [t] *)
3636

37-
val filter_chars : string -> (char -> bool) -> string
38-
(** filter chars from a string *)
39-
4037
val map_unlikely : string -> (char -> string option) -> string
4138
(** map a string trying to fill the buffer by chunk *)
4239

ocaml/xe-cli/dune

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
xapi-backtrace
1818
xapi-cli-protocol
1919
xapi-stdext-pervasives
20-
xapi-stdext-std
2120
xapi-stdext-unix
2221
)
2322
)

ocaml/xe-cli/newcli.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*)
1414
(* New cli talking to the in-server cli interface *)
1515

16-
module Stringext = Xapi_stdext_std.Xstringext.String
1716
open Xapi_stdext_pervasives
1817
open Cli_protocol
1918

@@ -306,7 +305,7 @@ let parse_args =
306305
|| (extra_args.[!i] = ',' && extra_args.[!i - 1] <> '\\')
307306
then (
308307
let seg = String.sub extra_args !pos (!i - !pos) in
309-
l := Stringext.filter_chars seg (( <> ) '\\') :: !l ;
308+
l := Astring.String.filter (( <> ) '\\') seg :: !l ;
310309
incr i ;
311310
pos := !i
312311
) else

0 commit comments

Comments
 (0)