Skip to content
This repository has been archived by the owner on Apr 24, 2021. It is now read-only.

Commit

Permalink
Convert some Str.split and remove Utils.split_on_char
Browse files Browse the repository at this point in the history
  • Loading branch information
chenglou committed Apr 15, 2021
1 parent fc94192 commit bd15389
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/FindFiles.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ let isSourceFile name =
|| Filename.check_suffix name ".mli"

let compiledNameSpace name =
Str.split (Str.regexp_string "-") name
String.split_on_char '-' name
|> List.map String.capitalize_ascii
|> String.concat ""
(* Remove underscores??? Whyyy bucklescript, whyyyy *)
|> Str.split (Str.regexp_string "_")
|> String.split_on_char '_'
|> String.concat ""

let compiledBaseName ~namespace name =
Expand Down
2 changes: 1 addition & 1 deletion src/Packages.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let newBsPackage rootPath =
match item |> Json.string with
| None -> opens
| Some s -> (
let parts = Utils.split_on_char ' ' s in
let parts = String.split_on_char ' ' s in
match parts with
| "-open" :: name :: _ -> name :: opens
| _ -> opens))
Expand Down
15 changes: 0 additions & 15 deletions src/Utils.ml
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
(*
steal from OCaml stdlib
https://github.com/ocaml/ocaml/blob/7c9c210884e1b46f21af5bb4dfab995bb3336cf7/stdlib/string.ml#L205-L214
*)
let split_on_char sep s =
let open String in
let r = ref [] in
let j = ref (length s) in
for i = length s - 1 downto 0 do
if unsafe_get s i = sep then (
r := sub s (i + 1) (!j - i - 1) :: !r;
j := i)
done;
sub s 0 !j :: !r

let topLoc fname =
{
Location.loc_start =
Expand Down

0 comments on commit bd15389

Please sign in to comment.