@@ -235680,18 +235680,11 @@ type t = string
235680235680
235681235681let curry = "Curry"
235682235682let rescriptPervasives = "RescriptPervasives"
235683- let dotRegex = "." |> Str.quote |> Str.regexp
235684- let lbracketRegex = "[" |> Str.quote |> Str.regexp
235685- let rbracketRegex = "]" |> Str.quote |> Str.regexp
235686235683
235687235684let sanitizeId s =
235688235685 let s =
235689235686 if String.contains s '.' || String.contains s '[' || String.contains s ']'
235690- then
235691- s
235692- |> Str.global_replace dotRegex "_"
235693- |> Str.global_replace lbracketRegex "_"
235694- |> Str.global_replace rbracketRegex "_"
235687+ then s |> String.map (function '.' | '[' | ']' -> '_' | c -> c)
235695235688 else s
235696235689 in
235697235690 if s <> "" && s.[0] >= 'A' && s.[0] <= 'z' then s else "_" ^ s
@@ -235784,7 +235777,9 @@ let getShims map =
235784235777 |> Array.iter (fun x ->
235785235778 match x with
235786235779 | Ext_json_types.Str { str } ->
235787- let fromTo = Str.split (Str.regexp "=") str |> Array.of_list in
235780+ let fromTo =
235781+ str |> String.split_on_char '=' |> Array.of_list
235782+ in
235788235783 assert (Array.length fromTo == 2);
235789235784 shims := (fromTo.(0), fromTo.(1)) :: !shims
235790235785 | _ -> ())
@@ -236020,8 +236015,12 @@ type labelJS =
236020236015type case = { label : string; labelJS : labelJS }
236021236016
236022236017let isJSSafePropertyName name =
236023- let jsSafeRegex = {|^[A-z][A-z0-9]*$|} |> Str.regexp in
236024- Str.string_match jsSafeRegex name 0
236018+ name = ""
236019+ || (match name.[0] with 'A' .. 'z' -> true | _ -> false)
236020+ && name
236021+ |> String.for_all (function
236022+ | 'A' .. 'z' | '0' .. '9' -> true
236023+ | _ -> false)
236025236024
236026236025let labelJSToString ?(alwaysQuotes = false) case =
236027236026 let addQuotes x =
@@ -236198,7 +236197,7 @@ let variantTable hash ~toJS =
236198236197let ident ?(builtin = true) ?(typeArgs = []) name =
236199236198 Ident { builtin; name; typeArgs }
236200236199
236201- let sanitizeTypeName name = name |> Str.global_replace (Str.regexp "'") "_"
236200+ let sanitizeTypeName name = name |> String.map (function '\'' -> '_' | c -> c)
236202236201let unknown = ident "unknown"
236203236202let booleanT = ident "boolean"
236204236203let dateT = ident "Date"
@@ -236224,7 +236223,7 @@ module NodeFilename = struct
236224236223
236225236224 let normalize path : t =
236226236225 match Sys.os_type with
236227- | "Win32" -> path |> Str.split (Str.regexp "\\") |> String.concat dirSep
236226+ | "Win32" -> path |> String.split_on_char '\\' |> String.concat dirSep
236228236227 | _ -> path
236229236228
236230236229 let toString path = path
@@ -236528,7 +236527,8 @@ and structureCheckAnnotation ~checkAnnotation (structure : Typedtree.structure)
236528236527 structure.str_items
236529236528 |> List.exists (structureItemCheckAnnotation ~checkAnnotation)
236530236529
236531- let sanitizeVariableName name = name |> Str.global_replace (Str.regexp "-") "_"
236530+ let sanitizeVariableName name =
236531+ name |> String.map (function '-' -> '_' | c -> c)
236532236532
236533236533let importFromString importString : import =
236534236534 let name =
@@ -240407,7 +240407,7 @@ let rec emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
240407240407 match valueName = asPath with
240408240408 | true -> (valueName, "")
240409240409 | false -> (
240410- match asPath |> Str.split (Str.regexp "\\.") with
240410+ match asPath |> String.split_on_char '.' with
240411240411 | x :: y -> (x, "" :: y |> String.concat ".")
240412240412 | _ -> (asPath, ""))
240413240413 in
0 commit comments