Skip to content

Commit 51f7dfa

Browse files
committed
daemon, generator: Use power of 2 for initial size of Hashtbl.create
Before 2011 it was recommended to use a prime number for the initial size. In 2011 the OCaml hash table was reimplemented using a hash function based on Murmur 3. Hashtbl.create now adjusts the initial size to the next power of 2 (minimum 16). So replace obsolete 'Hashtbl.create 13' with 'Hashtbl.create 16'.
1 parent cbe04b2 commit 51f7dfa

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

builder/builder.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let remove_duplicates index =
4646
* (name, arch) tuples, so it possible to ignore duplicates,
4747
* and versions with a lower revision.
4848
*)
49-
let nseen = Hashtbl.create 13 in
49+
let nseen = Hashtbl.create 16 in
5050
List.iter (
5151
fun (name, { Index.arch; revision }) ->
5252
let id = name, arch in

builder/index_parser.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let get_index ~downloader ~sigchecker ?(template = false)
5555
in
5656
n, (find_arch fields)
5757
) sections in
58-
let nseen = Hashtbl.create 13 in
58+
let nseen = Hashtbl.create 16 in
5959
List.iter (
6060
fun (n, arch) ->
6161
let id = n, arch in
@@ -71,7 +71,7 @@ let get_index ~downloader ~sigchecker ?(template = false)
7171
(* Check for repeated fields. *)
7272
List.iter (
7373
fun (n, fields) ->
74-
let fseen = Hashtbl.create 13 in
74+
let fseen = Hashtbl.create 16 in
7575
List.iter (
7676
fun (field, subkey, _) ->
7777
let hashkey = (field, subkey) in

resize/resize.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ read the man page virt-resize(1).
630630
* that the user has asked to be ignored or deleted.
631631
*)
632632
let find_partition =
633-
let hash = Hashtbl.create 13 in
633+
let hash = Hashtbl.create 16 in
634634
List.iter (fun ({ p_name = name } as p) -> Hashtbl.add hash name p)
635635
partitions;
636636
fun ~option name ->
@@ -881,7 +881,7 @@ read the man page virt-resize(1).
881881
surplus in
882882

883883
(* Mark the --lv-expand LVs. *)
884-
let hash = Hashtbl.create 13 in
884+
let hash = Hashtbl.create 16 in
885885
List.iter (fun ({ lv_name = name } as lv) -> Hashtbl.add hash name lv) lvs;
886886

887887
List.iter (

0 commit comments

Comments
 (0)