Commit 0585799 1 parent 6beeb02 commit 0585799 Copy full SHA for 0585799
File tree 1 file changed +12
-14
lines changed
1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -216,20 +216,18 @@ let remove_file file =
216
216
internal_error " Cannot remove %s (%s)." file (Printexc. to_string e)
217
217
)
218
218
219
- let string_of_channel ic =
220
- let n = 32768 in
221
- let s = Bytes. create n in
222
- let b = Buffer. create 1024 in
223
- let rec iter ic b s =
224
- let nread =
225
- try input ic s 0 n
226
- with End_of_file -> 0 in
227
- if nread > 0 then (
228
- Buffer. add_subbytes b s 0 nread;
229
- iter ic b s
230
- ) in
231
- iter ic b s;
232
- Buffer. contents b
219
+ let string_of_channel =
220
+ let n = 4096 in
221
+ let b = Buffer. create n in
222
+ let rec iter ic b =
223
+ match Buffer. add_channel b ic n with
224
+ | () -> iter ic b
225
+ | exception End_of_file -> ()
226
+ in
227
+ fun ic ->
228
+ Buffer. clear b;
229
+ iter ic b;
230
+ Buffer. contents b
233
231
234
232
let read file =
235
233
let ic =
You can’t perform that action at this time.
0 commit comments