2121 These functions have a "duplicated" comment above their definition.
2222*)
2323
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"
2433external length : bytes -> int = " %bytes_length"
2534external% private string_length : string -> int = " %string_length"
2635external get : bytes -> int -> char = " %bytes_safe_get"
@@ -86,15 +95,15 @@ let unsafe_blit (s1:bytes) i1 (s2:bytes) i2 len =
8695
8796let unsafe_blit_string (s1 : string ) i1 (s2 : bytes ) i2 (len : int ) =
8897 if len > 0 then
89- let off1 = Caml_string_extern. length s1 - i1 in
98+ let off1 = string_length s1 - i1 in
9099 if len < = off1 then
91100 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)
93102 done
94103 else
95104 begin
96105 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)
98107 done ;
99108 for i = off1 to len - 1 do
100109 s2.! [i2 + i] < - '\000'
@@ -105,7 +114,7 @@ let string_of_large_bytes (bytes : bytes) i len =
105114 let s_len = ref len in
106115 let seg = 1024 in
107116 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)
109118 else
110119 begin
111120 let offset = ref 0 in
@@ -115,7 +124,7 @@ let string_of_large_bytes (bytes : bytes) i len =
115124 for k = 0 to next - 1 do
116125 tmp_bytes.! [k] < - bytes.! [k + offset.contents]
117126 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);
119128 s_len.contents < - s_len.contents - next ;
120129 offset.contents < - offset.contents + next;
121130 done ;
@@ -153,7 +162,7 @@ let of_string (s : string) =
153162 let len = string_length s in
154163 let res = new_uninitialized len in
155164 for i = 0 to len - 1 do
156- res.! [i] < - Caml_string_extern. unsafe_get s i
165+ res.! [i] < - s. ! (i)
157166 (* Note that when get a char and convert it to int immedately, should be optimized
158167 should be [s.charCodeAt[i]]
159168 *)
0 commit comments