Fix Hashtbl.Make.of_seq creating randomized tables

Book-keeping error only - although it does potentially initialise the PRNG
unnecessarily.
master
David Allsopp 2018-12-16 17:26:49 +01:00 committed by Xavier Leroy
parent fc8be501aa
commit 947486007e
3 changed files with 18 additions and 1 deletions

View File

@ -356,7 +356,8 @@ OCaml 4.08.0
(Pierre Weis, Richard Bonichon, review by Florian Angeletti)
- GPR#2202: Correct Hashtbl.MakeSeeded.{add_seq,replace_seq,of_seq} to use
functor hash function instead of default hash function.
functor hash function instead of default hash function. Hashtbl.Make.of_seq
shouldn't create randomized hash tables.
(David Allsopp, review by Alain Frisch)
### Other libraries:

View File

@ -482,6 +482,10 @@ module K1 = struct
let hash (_seed: int) x = H.hash x
end)
let create sz = create ~random:false sz
let of_seq i =
let tbl = create 16 in
replace_seq tbl i;
tbl
end
end
@ -570,6 +574,10 @@ module K2 = struct
let hash (_seed: int) x = H2.hash x
end)
let create sz = create ~random:false sz
let of_seq i =
let tbl = create 16 in
replace_seq tbl i;
tbl
end
end
@ -670,5 +678,9 @@ module Kn = struct
let hash (_seed: int) x = H.hash x
end)
let create sz = create ~random:false sz
let of_seq i =
let tbl = create 16 in
replace_seq tbl i;
tbl
end
end

View File

@ -599,4 +599,8 @@ module Make(H: HashedType): (S with type key = H.t) =
let hash (_seed: int) x = H.hash x
end)
let create sz = create ~random:false sz
let of_seq i =
let tbl = create 16 in
replace_seq tbl i;
tbl
end