Hashtbl: remove support for pre-4.00 hash tables
When the hash function and the internal representation of hash tables was changed in 4.00, some compatibility code was left so that "old" hash tables (created with OCaml < 4.00 and marshaled to files) could still be operated upon by the functions of the new implementation. This was 9 years ago, so it is reasonable to expect that none of these "old" hash tables are still in use. This commit removes the compatibility code in stdlib/hashtbl.ml. It still tries to detect "old" hash tables and raise an Invalid_argument exception instead of crashing.master
parent
a6f03cc10f
commit
40399cca5e
|
@ -493,18 +493,15 @@ module Make(H: HashedType): (S with type key = H.t) =
|
|||
|
||||
external seeded_hash_param :
|
||||
int -> int -> int -> 'a -> int = "caml_hash" [@@noalloc]
|
||||
external old_hash_param :
|
||||
int -> int -> 'a -> int = "caml_hash_univ_param" [@@noalloc]
|
||||
|
||||
let hash x = seeded_hash_param 10 100 0 x
|
||||
let hash_param n1 n2 x = seeded_hash_param n1 n2 0 x
|
||||
let seeded_hash seed x = seeded_hash_param 10 100 seed x
|
||||
|
||||
let key_index h key =
|
||||
(* compatibility with old hash tables *)
|
||||
if Obj.size (Obj.repr h) >= 3
|
||||
if Obj.size (Obj.repr h) >= 4
|
||||
then (seeded_hash_param 10 100 h.seed key) land (Array.length h.data - 1)
|
||||
else (old_hash_param 10 100 key) mod (Array.length h.data)
|
||||
else invalid_arg "Hashtbl: unsupported hash table format"
|
||||
|
||||
let add h key data =
|
||||
let i = key_index h key in
|
||||
|
@ -630,4 +627,3 @@ let rebuild ?(random = !randomized) h =
|
|||
} in
|
||||
insert_all_buckets (key_index h') false h.data h'.data;
|
||||
h'
|
||||
|
||||
|
|
|
@ -498,4 +498,3 @@ val seeded_hash_param : int -> int -> int -> 'a -> int
|
|||
an integer seed. Usage:
|
||||
[Hashtbl.seeded_hash_param meaningful total seed x].
|
||||
@since 4.00.0 *)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ Uncaught exception Invalid_argument("index out of bounds")
|
|||
Raised by primitive operation at Backtrace2.run in file "backtrace2.ml", line 62, characters 14-22
|
||||
test_Not_found
|
||||
Uncaught exception Not_found
|
||||
Raised at Stdlib__hashtbl.find in file "hashtbl.ml", line 537, characters 13-28
|
||||
Raised at Stdlib__hashtbl.find in file "hashtbl.ml", line 538, characters 13-28
|
||||
Called from Backtrace2.test_Not_found in file "backtrace2.ml", line 43, characters 9-42
|
||||
Re-raised at Backtrace2.test_Not_found in file "backtrace2.ml", line 43, characters 61-70
|
||||
Called from Backtrace2.run in file "backtrace2.ml", line 62, characters 11-23
|
||||
|
@ -50,7 +50,7 @@ Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", lin
|
|||
Re-raised at CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 36, characters 4-11
|
||||
Called from Backtrace2.run in file "backtrace2.ml", line 62, characters 11-23
|
||||
Uncaught exception Not_found
|
||||
Raised at Stdlib__hashtbl.find in file "hashtbl.ml", line 537, characters 13-28
|
||||
Raised at Stdlib__hashtbl.find in file "hashtbl.ml", line 538, characters 13-28
|
||||
Called from Backtrace2.test_lazy.exception_raised_internally in file "backtrace2.ml", line 50, characters 8-41
|
||||
Re-raised at CamlinternalLazy.force_lazy_block.(fun) in file "camlinternalLazy.ml", line 35, characters 56-63
|
||||
Called from CamlinternalLazy.force_lazy_block in file "camlinternalLazy.ml", line 31, characters 17-27
|
||||
|
|
Loading…
Reference in New Issue