Skip to content

Commit

Permalink
Simplify Package.hash
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremie Dimino <[email protected]>
  • Loading branch information
jeremiedimino authored and rgrinberg committed May 7, 2019
1 parent c9c858d commit 94c5cb5
Showing 1 changed file with 4 additions and 34 deletions.
38 changes: 4 additions & 34 deletions src/package.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ module Dependency = struct
| And of t list
| Or of t list

let hash = Poly.hash

let decode =
let open Dune_lang.Decoder in
let ops =
Expand Down Expand Up @@ -146,12 +144,6 @@ module Dependency = struct
; constraint_ : Constraint.t option
}

let hash { name ; constraint_ } =
Poly.hash
( Name.hash name
, Option.hash Constraint.hash constraint_
)

let decode =
let open Dune_lang.Decoder in
let constrained =
Expand Down Expand Up @@ -209,8 +201,6 @@ module Kind = struct
| Dune of has_opam
| Opam

let hash = Poly.hash

let to_dyn =
let open Dyn.Encoder in
function
Expand All @@ -232,30 +222,10 @@ type t =
; tags : string list
}

let hash { name
; synopsis
; description
; depends
; conflicts
; depopts
; path
; version
; kind
; tags
; loc = _
} =
Hashtbl.hash
( Name.hash name
, Option.hash String.hash synopsis
, Option.hash String.hash description
, List.hash Dependency.hash depends
, List.hash Dependency.hash conflicts
, List.hash Dependency.hash depopts
, Path.Source.hash path
, Hashtbl.hash version
, Kind.hash kind
, Poly.hash tags
)
(* Package name are globally unique, so we can reasonably expect that
there will always be only a single value of type [t] with a given
name in memory. That's why we only hash the name. *)
let hash t = Name.hash t.name

let decode ~dir =
let open Dune_lang.Decoder in
Expand Down

0 comments on commit 94c5cb5

Please sign in to comment.