Merge branch 'master' into remove-concat-or-split
This commit is contained in:
commit
bc53047a95
|
@ -4,6 +4,7 @@ module Name = struct
|
||||||
include Interned.Make(struct
|
include Interned.Make(struct
|
||||||
let initial_size = 16
|
let initial_size = 16
|
||||||
let resize_policy = Interned.Conservative
|
let resize_policy = Interned.Conservative
|
||||||
|
let order = Interned.Natural
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
let of_string = make
|
let of_string = make
|
||||||
|
|
|
@ -22,24 +22,26 @@ end
|
||||||
|
|
||||||
type resize_policy = Conservative | Greedy
|
type resize_policy = Conservative | Greedy
|
||||||
|
|
||||||
|
type order = Natural | Fast
|
||||||
|
|
||||||
let new_size ~next ~size = function
|
let new_size ~next ~size = function
|
||||||
| Conservative ->
|
| Conservative ->
|
||||||
let increment_size = 512 in
|
let increment_size = 512 in
|
||||||
(next land (lnot (increment_size - 1))) + (increment_size * 2)
|
(next land (lnot (increment_size - 1))) + (increment_size * 2)
|
||||||
| Greedy -> size * 2
|
| Greedy -> size * 2
|
||||||
|
|
||||||
module Make(R : sig
|
module type Settings = sig
|
||||||
val resize_policy : resize_policy
|
val initial_size : int
|
||||||
val initial_size : int
|
val resize_policy : resize_policy
|
||||||
end)()
|
val order : order
|
||||||
|
end
|
||||||
|
|
||||||
|
module Make(R : Settings)()
|
||||||
= struct
|
= struct
|
||||||
type t = int
|
|
||||||
|
|
||||||
let ids = Hashtbl.create 1024
|
let ids = Hashtbl.create 1024
|
||||||
let next = ref 0
|
let next = ref 0
|
||||||
|
|
||||||
let compare = Int.compare
|
|
||||||
|
|
||||||
module Table = struct
|
module Table = struct
|
||||||
type 'a t =
|
type 'a t =
|
||||||
{ default_value : 'a
|
{ default_value : 'a
|
||||||
|
@ -86,10 +88,21 @@ module Make(R : sig
|
||||||
|
|
||||||
let to_string t = Table.get names t
|
let to_string t = Table.get names t
|
||||||
|
|
||||||
|
module T = struct
|
||||||
|
type nonrec t = int
|
||||||
|
|
||||||
|
let compare =
|
||||||
|
match R.order with
|
||||||
|
| Fast -> Int.compare
|
||||||
|
| Natural -> fun x y -> String.compare (to_string x) (to_string y)
|
||||||
|
end
|
||||||
|
|
||||||
|
include T
|
||||||
|
|
||||||
let pp fmt t = Format.fprintf fmt "%S" (to_string t)
|
let pp fmt t = Format.fprintf fmt "%S" (to_string t)
|
||||||
|
|
||||||
module Set = struct
|
module Set = struct
|
||||||
include Int.Set
|
include Set.Make(T)
|
||||||
|
|
||||||
let make l =
|
let make l =
|
||||||
List.fold_left l ~init:empty ~f:(fun acc s -> add acc (make s))
|
List.fold_left l ~init:empty ~f:(fun acc s -> add acc (make s))
|
||||||
|
@ -97,12 +110,7 @@ module Make(R : sig
|
||||||
let pp fmt (t : t) = Fmt.ocaml_list pp fmt (to_list t)
|
let pp fmt (t : t) = Fmt.ocaml_list pp fmt (to_list t)
|
||||||
end
|
end
|
||||||
|
|
||||||
module Map = Int.Map
|
module Map = Map.Make(T)
|
||||||
end
|
|
||||||
|
|
||||||
module type Settings = sig
|
|
||||||
val initial_size : int
|
|
||||||
val resize_policy : resize_policy
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module No_interning(R : Settings)() = struct
|
module No_interning(R : Settings)() = struct
|
||||||
|
|
|
@ -36,9 +36,12 @@ end
|
||||||
|
|
||||||
type resize_policy = Conservative | Greedy
|
type resize_policy = Conservative | Greedy
|
||||||
|
|
||||||
|
type order = Natural | Fast
|
||||||
|
|
||||||
module type Settings = sig
|
module type Settings = sig
|
||||||
val initial_size : int
|
val initial_size : int
|
||||||
val resize_policy : resize_policy
|
val resize_policy : resize_policy
|
||||||
|
val order : order
|
||||||
end
|
end
|
||||||
|
|
||||||
module Make(R : Settings)() : S
|
module Make(R : Settings)() : S
|
||||||
|
|
|
@ -51,6 +51,7 @@ end = struct
|
||||||
include Interned.No_interning(struct
|
include Interned.No_interning(struct
|
||||||
let initial_size = 512
|
let initial_size = 512
|
||||||
let resize_policy = Interned.Greedy
|
let resize_policy = Interned.Greedy
|
||||||
|
let order = Interned.Natural
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
let compare_val x y = String.compare (to_string x) (to_string y)
|
let compare_val x y = String.compare (to_string x) (to_string y)
|
||||||
|
@ -157,6 +158,7 @@ end = struct
|
||||||
include Interned.No_interning(struct
|
include Interned.No_interning(struct
|
||||||
let initial_size = 512
|
let initial_size = 512
|
||||||
let resize_policy = Interned.Greedy
|
let resize_policy = Interned.Greedy
|
||||||
|
let order = Interned.Natural
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
let compare_val x y = String.compare (to_string x) (to_string y)
|
let compare_val x y = String.compare (to_string x) (to_string y)
|
||||||
|
|
|
@ -3,4 +3,5 @@ open Stdune
|
||||||
include Interned.Make(struct
|
include Interned.Make(struct
|
||||||
let initial_size = 16
|
let initial_size = 16
|
||||||
let resize_policy = Interned.Conservative
|
let resize_policy = Interned.Conservative
|
||||||
|
let order = Interned.Natural
|
||||||
end)()
|
end)()
|
||||||
|
|
|
@ -3,6 +3,7 @@ open Stdune
|
||||||
include Interned.Make(struct
|
include Interned.Make(struct
|
||||||
let initial_size = 256
|
let initial_size = 256
|
||||||
let resize_policy = Interned.Conservative
|
let resize_policy = Interned.Conservative
|
||||||
|
let order = Interned.Fast
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
let ppx_driver = make "ppx_driver"
|
let ppx_driver = make "ppx_driver"
|
||||||
|
|
Loading…
Reference in New Issue