Commit ff1c7ac 1 parent ebff21b commit ff1c7ac Copy full SHA for ff1c7ac
File tree 6 files changed +58
-14
lines changed
6 files changed +58
-14
lines changed Original file line number Diff line number Diff line change @@ -180,3 +180,4 @@ users)
180
180
181
181
## opam-core
182
182
* ` OpamStd.Env ` : add ` env_string_list ` for parsing string list environment variables (comma separated) [ #5682 @desumn ]
183
+ * ` OpamSystem.read ` : Speedup by using ` Stdlib.In_channel.input_all ` when available [ #5896 @kit-ty-kate ]
Original file line number Diff line number Diff line change 27
27
(write-file opamVersionInfo.ml
28
28
"let version = \"%{read-strings:version}\""))
29
29
30
+ (rule
31
+ (enabled_if (>= %{ocaml_version} "4.14"))
32
+ (action (copy opamCompatInChannel.real.ml opamCompatInChannel.ml)))
33
+ (rule
34
+ (enabled_if (< %{ocaml_version} "4.14"))
35
+ (action (copy opamCompatInChannel.compat.ml opamCompatInChannel.ml)))
36
+
30
37
(rule
31
38
(targets version)
32
39
(deps ../../shell/get_version.ml ../../configure.ac)
Original file line number Diff line number Diff line change
1
+ (* *************************************************************************)
2
+ (* *)
3
+ (* Copyright 2024 Kate Deplaix *)
4
+ (* *)
5
+ (* All rights reserved. This file is distributed under the terms of the *)
6
+ (* GNU Lesser General Public License version 2.1, with the special *)
7
+ (* exception on linking described in the file LICENSE. *)
8
+ (* *)
9
+ (* *************************************************************************)
10
+
11
+ let input_all ic =
12
+ let n = 32768 in
13
+ let s = Bytes. create n in
14
+ let b = Buffer. create 1024 in
15
+ let rec iter ic b s =
16
+ let nread =
17
+ try input ic s 0 n
18
+ with End_of_file -> 0 in
19
+ if nread > 0 then (
20
+ Buffer. add_subbytes b s 0 nread;
21
+ iter ic b s
22
+ ) in
23
+ iter ic b s;
24
+ Buffer. contents b
Original file line number Diff line number Diff line change
1
+ (* *************************************************************************)
2
+ (* *)
3
+ (* Copyright 2024 Kate Deplaix *)
4
+ (* *)
5
+ (* All rights reserved. This file is distributed under the terms of the *)
6
+ (* GNU Lesser General Public License version 2.1, with the special *)
7
+ (* exception on linking described in the file LICENSE. *)
8
+ (* *)
9
+ (* *************************************************************************)
10
+
11
+ (* * Compatibility module for Stdlib.In_channel which was added in OCaml 4.14 *)
12
+
13
+ (* * Emulates or aliases [Stdlib.In_channel.input_all] *)
14
+ val input_all : Stdlib .in_channel -> string
Original file line number Diff line number Diff line change
1
+ (* *************************************************************************)
2
+ (* *)
3
+ (* Copyright 2024 Kate Deplaix *)
4
+ (* *)
5
+ (* All rights reserved. This file is distributed under the terms of the *)
6
+ (* GNU Lesser General Public License version 2.1, with the special *)
7
+ (* exception on linking described in the file LICENSE. *)
8
+ (* *)
9
+ (* *************************************************************************)
10
+
11
+ include Stdlib. In_channel
Original file line number Diff line number Diff line change @@ -221,20 +221,7 @@ let remove_file file =
221
221
internal_error " Cannot remove %s (%s)." file (Printexc. to_string e)
222
222
)
223
223
224
- let string_of_channel ic =
225
- let n = 32768 in
226
- let s = Bytes. create n in
227
- let b = Buffer. create 1024 in
228
- let rec iter ic b s =
229
- let nread =
230
- try input ic s 0 n
231
- with End_of_file -> 0 in
232
- if nread > 0 then (
233
- Buffer. add_subbytes b s 0 nread;
234
- iter ic b s
235
- ) in
236
- iter ic b s;
237
- Buffer. contents b
224
+ let string_of_channel = OpamCompatInChannel. input_all
238
225
239
226
let read file =
240
227
let ic =
You can’t perform that action at this time.
0 commit comments