Skip to content

Commit b0bc8af

Browse files
committed
clean up
1 parent d65b5a4 commit b0bc8af

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

jscomp/runtime/caml_format.ml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525

2626

27-
external (.![]) : string -> int -> int = "%string_unsafe_get"
27+
external (.![]) : string -> int -> int = "%string_unsafe_get"
28+
external (.!()) : string -> int -> char = "%string_unsafe_get"
2829

2930
let code_0 = "0".![0]
3031
let code_a = "a".![0]
@@ -35,7 +36,7 @@ module Caml_char = struct
3536
external unsafe_chr : int -> char = "%identity"
3637
end
3738

38-
let caml_failwith s = raise (Failure s)
39+
let failwith s = raise (Failure s)
3940
(* let caml_invalid_argument s= raise (Invalid_argument s ) *)
4041

4142
let (>>>) = Caml_nativeint_extern.shift_right_logical
@@ -94,41 +95,39 @@ let parse_sign_and_base (s : string) =
9495

9596

9697
let caml_int_of_string s =
97-
let module String = Caml_string_extern in
9898
let i, sign, hbase = parse_sign_and_base s in
9999
let base = Caml_nativeint_extern.of_int (int_of_string_base hbase) in
100100
let threshold = (-1n >>> 0) in
101101
let len =Caml_string_extern.length s in
102-
let c = if i < len then s.[i] else '\000' in
102+
let c = if i < len then s.!(i) else '\000' in
103103
let d = to_nat (parse_digit c) in
104104
let () =
105105
if d < 0n || d >= base then
106-
caml_failwith "int_of_string" in
106+
failwith "int_of_string" in
107107
(* let () = [%bs.debugger] in *)
108108
let rec aux acc k =
109109
if k = len then acc
110110
else
111-
let a = s.[k] in
111+
let a = s.!(k) in
112112
if a = '_' then aux acc ( k + 1)
113113
else
114114
let v = to_nat (parse_digit a) in
115115
if v < 0n || v >= base then
116-
caml_failwith "int_of_string"
116+
failwith "int_of_string"
117117
else
118118
let acc = base *~ acc +~ v in
119119
if acc > threshold then
120-
caml_failwith "int_of_string"
120+
failwith "int_of_string"
121121
else aux acc ( k + 1)
122122
in
123123
let res = sign *~ aux d (i + 1) in
124124
let or_res = Caml_nativeint_extern.logor res 0n in
125125
(if base = 10n && res <> or_res then
126-
caml_failwith "int_of_string");
126+
failwith "int_of_string");
127127
or_res
128128

129129

130130
let caml_int64_of_string s =
131-
let module String = Caml_string_extern in
132131
let i, sign, hbase = parse_sign_and_base s in
133132
let base = Caml_int64_extern.of_int (int_of_string_base hbase) in
134133
let sign = Caml_int64_extern.of_nativeint sign in
@@ -144,31 +143,31 @@ let caml_int64_of_string s =
144143
9223372036854775807L
145144
in
146145
let len =Caml_string_extern.length s in
147-
let c = if i < len then s.[i] else '\000' in
146+
let c = if i < len then s.!(i) else '\000' in
148147
let d = Caml_int64_extern.of_int (parse_digit c) in
149148
let () =
150149
if d < 0L || d >= base then
151-
caml_failwith "int64_of_string" in
150+
failwith "int64_of_string" in
152151
let (+~) = Caml_int64_extern.add in
153152
let ( *~ ) = Caml_int64_extern.mul in
154153

155154
let rec aux acc k =
156155
if k = len then acc
157156
else
158-
let a = s.[k] in
157+
let a = s.!(k) in
159158
if a = '_' then aux acc ( k + 1)
160159
else
161160
let v = Caml_int64_extern.of_int (parse_digit a) in
162161
if v < 0L || v >= base || acc > threshold then
163-
caml_failwith "int64_of_string"
162+
failwith "int64_of_string"
164163
else
165164
let acc = base *~ acc +~ v in
166165
aux acc ( k + 1)
167166
in
168167
let res = sign *~ aux d (i + 1) in
169168
let or_res = Caml_int64_extern.logor res 0L in
170169
(if base = 10L && res <> or_res then
171-
caml_failwith "int64_of_string");
170+
failwith "int64_of_string");
172171
or_res
173172

174173
type base =

0 commit comments

Comments
 (0)