21
21
These functions have a "duplicated" comment above their definition.
22
22
*)
23
23
24
+
25
+
26
+ external of_small_int_array :
27
+ (_ [@ bs.as {json| null| json}] ) ->
28
+ int array -> string =
29
+ " String.fromCharCode.apply"
30
+ [@@ bs.val]
31
+
32
+ external (.! () ) : string -> int -> char = " %string_unsafe_get"
24
33
external length : bytes -> int = " %bytes_length"
25
34
external% private string_length : string -> int = " %string_length"
26
35
external get : bytes -> int -> char = " %bytes_safe_get"
@@ -86,15 +95,15 @@ let unsafe_blit (s1:bytes) i1 (s2:bytes) i2 len =
86
95
87
96
let unsafe_blit_string (s1 : string ) i1 (s2 : bytes ) i2 (len : int ) =
88
97
if len > 0 then
89
- let off1 = Caml_string_extern. length s1 - i1 in
98
+ let off1 = string_length s1 - i1 in
90
99
if len < = off1 then
91
100
for i = 0 to len - 1 do
92
- s2.! [i2 + i] < - Caml_string_extern. unsafe_get s1 (i1 + i)
101
+ s2.! [i2 + i] < - s1. ! (i1 + i)
93
102
done
94
103
else
95
104
begin
96
105
for i = 0 to off1 - 1 do
97
- s2.! [i2 + i] < - Caml_string_extern. unsafe_get s1 (i1 + i)
106
+ s2.! [i2 + i] < - s1. ! (i1 + i)
98
107
done ;
99
108
for i = off1 to len - 1 do
100
109
s2.! [i2 + i] < - '\000'
@@ -105,7 +114,7 @@ let string_of_large_bytes (bytes : bytes) i len =
105
114
let s_len = ref len in
106
115
let seg = 1024 in
107
116
if i = 0 && len < = 4 * seg && len = length bytes then
108
- Caml_string_extern. of_small_int_array (to_int_array bytes)
117
+ of_small_int_array (to_int_array bytes)
109
118
else
110
119
begin
111
120
let offset = ref 0 in
@@ -115,7 +124,7 @@ let string_of_large_bytes (bytes : bytes) i len =
115
124
for k = 0 to next - 1 do
116
125
tmp_bytes.! [k] < - bytes.! [k + offset.contents]
117
126
done ;
118
- s.contents < - s.contents ^ Caml_string_extern. of_small_int_array (to_int_array tmp_bytes);
127
+ s.contents < - s.contents ^ of_small_int_array (to_int_array tmp_bytes);
119
128
s_len.contents < - s_len.contents - next ;
120
129
offset.contents < - offset.contents + next;
121
130
done ;
@@ -153,7 +162,7 @@ let of_string (s : string) =
153
162
let len = string_length s in
154
163
let res = new_uninitialized len in
155
164
for i = 0 to len - 1 do
156
- res.! [i] < - Caml_string_extern. unsafe_get s i
165
+ res.! [i] < - s. ! (i)
157
166
(* Note that when get a char and convert it to int immedately, should be optimized
158
167
should be [s.charCodeAt[i]]
159
168
*)
0 commit comments