Skip to content

Commit

Permalink
File_tree.File simplification
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Apr 1, 2020
1 parent 6437512 commit c76bfed
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/dune/file_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,29 @@ open! Stdune
open Import

module File = struct
type t =
{ ino : int
; dev : int
}
module T = struct
type t =
{ ino : int
; dev : int
}

let to_dyn { ino; dev } =
let open Dyn.Encoder in
record [ ("ino", Int.to_dyn ino); ("dev", Int.to_dyn dev) ]
let to_dyn { ino; dev } =
let open Dyn.Encoder in
record [ ("ino", Int.to_dyn ino); ("dev", Int.to_dyn dev) ]

let compare a b =
match Int.compare a.ino b.ino with
| Eq -> Int.compare a.dev b.dev
| ne -> ne
let compare a b =
match Int.compare a.ino b.ino with
| Eq -> Int.compare a.dev b.dev
| ne -> ne
end

include T

let dummy = { ino = 0; dev = 0 }

let of_stats (st : Unix.stats) = { ino = st.st_ino; dev = st.st_dev }

module Map = Map.Make (struct
type nonrec t = t

let compare = compare

let to_dyn _ = Dyn.opaque
end)
module Map = Map.Make (T)

let of_source_path p = of_stats (Path.stat (Path.source p))
end
Expand Down

0 comments on commit c76bfed

Please sign in to comment.