Skip to content

Commit

Permalink
Use compiler-libs' compression for read cmi and cmt files
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Nov 27, 2023
1 parent afd9b35 commit 2230f56
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/ocaml/compression/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(library
(name ocaml_compression)
(public_name merlin-lib.ocaml_compression)
(libraries compiler-libs.common))
3 changes: 3 additions & 0 deletions src/ocaml/compression/ocaml_compression.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

(** We rely on [compiler-libs] for compression *)
include Compression
4 changes: 2 additions & 2 deletions src/ocaml/typing/cmi_format.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type cmi_infos = {
}

let input_cmi ic =
let (name, sign) = (input_value ic : header) in
let (name, sign) = (Ocaml_compression.input_value ic : header) in
let crcs = (input_value ic : crcs) in
let flags = (input_value ic : flags) in
{
Expand Down Expand Up @@ -76,7 +76,7 @@ let read_cmi filename =
let output_cmi filename oc cmi =
(* beware: the provided signature must have been substituted for saving *)
output_string oc Config.cmi_magic_number;
output_value oc ((cmi.cmi_name, cmi.cmi_sign) : header);
Ocaml_compression.output_value oc ((cmi.cmi_name, cmi.cmi_sign) : header);
flush oc;
let crc = Digest.file filename in
let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in
Expand Down
4 changes: 2 additions & 2 deletions src/ocaml/typing/cmt_format.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ let clear_env binary_annots =

exception Error of error

let input_cmt ic = (input_value ic : cmt_infos)
let input_cmt ic = (Ocaml_compression.input_value ic : cmt_infos)

let output_cmt oc cmt =
output_string oc Config.cmt_magic_number;
output_value oc (cmt : cmt_infos)
Ocaml_compression.output_value oc (cmt : cmt_infos)

let read filename =
(* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *)
Expand Down
2 changes: 1 addition & 1 deletion src/ocaml/typing/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
-open Merlin_utils
(:standard -w -9))
(modules_without_implementation annot outcometree)
(libraries merlin_utils ocaml_parsing ocaml_utils))
(libraries merlin_utils ocaml_compression ocaml_parsing ocaml_utils))

0 comments on commit 2230f56

Please sign in to comment.