@@ -148,7 +148,7 @@ let rec add_utf_16le_uchar b u =
148
148
149
149
let add_substring b s offset len =
150
150
if offset < 0 || len < 0 || offset > String. length s - len
151
- then invalid_arg " Buffer.add_substring/add_subbytes " ;
151
+ then invalid_arg " Buffer.add_substring" ;
152
152
let position = b.position in
153
153
let {buffer;length} = b.inner in
154
154
let new_position = position + len in
@@ -159,22 +159,24 @@ let add_substring b s offset len =
159
159
Bytes. unsafe_blit_string s offset buffer position len;
160
160
b.position < - new_position
161
161
162
- let add_subbytes b s offset len =
163
- add_substring b (Bytes. unsafe_to_string s) offset len
164
-
165
- let add_string b s =
166
- let len = String. length s in
162
+ let add_subbytes b bytes offset len =
163
+ if offset < 0 || len < 0 || offset > Bytes. length bytes - len
164
+ then invalid_arg " Buffer.add_subbytes" ;
167
165
let position = b.position in
168
- let {buffer; length} = b.inner in
166
+ let {buffer;length} = b.inner in
169
167
let new_position = position + len in
170
168
if new_position > length then (
171
169
resize b len;
172
- Bytes. blit_string s 0 b.inner.buffer b.position len;
170
+ Bytes. blit bytes offset b.inner.buffer b.position len
173
171
) else
174
- Bytes. unsafe_blit_string s 0 buffer position len;
172
+ Bytes. unsafe_blit bytes offset buffer position len;
175
173
b.position < - new_position
176
174
177
- let add_bytes b s = add_string b (Bytes. unsafe_to_string s)
175
+ let add_string b s =
176
+ add_substring b s 0 (String. length s)
177
+
178
+ let add_bytes b bytes =
179
+ add_subbytes b bytes 0 (Bytes. length bytes)
178
180
179
181
let add_buffer b bs =
180
182
add_subbytes b bs.inner.buffer 0 bs.position
0 commit comments