Commit e5dac9f 1 parent c8366f7 commit e5dac9f Copy full SHA for e5dac9f
File tree 2 files changed +9
-12
lines changed
2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -121,3 +121,4 @@ users)
121
121
## opam-format
122
122
123
123
## opam-core
124
+ * ` OpamSystem.read ` : Speedup by 8% [ #5896 @kit-ty-kate ]
Original file line number Diff line number Diff line change @@ -217,18 +217,14 @@ let remove_file file =
217
217
)
218
218
219
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;
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
+ iter ic b;
232
228
Buffer. contents b
233
229
234
230
let read file =
You can’t perform that action at this time.
0 commit comments