102 lines
3.3 KiB
Diff
102 lines
3.3 KiB
Diff
From 495f71affc7ade1842a8bc66f5f65862c444ca93 Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Fri, 12 Sep 2025 08:37:58 +0100
|
|
Subject: [PATCH] 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'.
|
|
---
|
|
daemon/selinux.ml | 2 +-
|
|
generator/memoized_cache.ml | 2 +-
|
|
generator/optgroups.ml | 2 +-
|
|
generator/pr.ml | 2 +-
|
|
generator/tests_c_api.ml | 2 +-
|
|
generator/utils.ml | 2 +-
|
|
6 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/daemon/selinux.ml b/daemon/selinux.ml
|
|
index 2b49e5eba..9802e8913 100644
|
|
--- a/daemon/selinux.ml
|
|
+++ b/daemon/selinux.ml
|
|
@@ -35,7 +35,7 @@ let setfiles_has_option =
|
|
let _, _, err = commandr "setfiles" [opt] in
|
|
String.find err err_msg = -1
|
|
in
|
|
- let h = Hashtbl.create 13 in
|
|
+ let h = Hashtbl.create 16 in
|
|
fun flag ->
|
|
try Hashtbl.find h flag
|
|
with
|
|
diff --git a/generator/memoized_cache.ml b/generator/memoized_cache.ml
|
|
index 46ba929a3..8ae224edc 100644
|
|
--- a/generator/memoized_cache.ml
|
|
+++ b/generator/memoized_cache.ml
|
|
@@ -44,7 +44,7 @@ let create ?(version = 1) ?(batch_size = 100) name lookup_fn =
|
|
let filename = sprintf "generator/.%s.data.version.%d" name version in
|
|
let memo =
|
|
try with_open_in filename input_value
|
|
- with _ -> Hashtbl.create 13 in
|
|
+ with _ -> Hashtbl.create 16 in
|
|
{
|
|
memo; filename; lookup_fn; batch_size; unsaved_count = 0;
|
|
}
|
|
diff --git a/generator/optgroups.ml b/generator/optgroups.ml
|
|
index 43c9fe75a..f65f0ccbd 100644
|
|
--- a/generator/optgroups.ml
|
|
+++ b/generator/optgroups.ml
|
|
@@ -34,7 +34,7 @@ let optgroups_retired = [
|
|
|
|
(* Create list of optional groups. *)
|
|
let optgroups =
|
|
- let h = Hashtbl.create 13 in
|
|
+ let h = Hashtbl.create 16 in
|
|
List.iter (
|
|
function
|
|
| { optional = Some group } as fn ->
|
|
diff --git a/generator/pr.ml b/generator/pr.ml
|
|
index af9da9f68..615c241d0 100644
|
|
--- a/generator/pr.ml
|
|
+++ b/generator/pr.ml
|
|
@@ -32,7 +32,7 @@ let lines = ref 0
|
|
|
|
(* Name of each file generated. *)
|
|
let files = ref []
|
|
-let fileshash = Hashtbl.create 13
|
|
+let fileshash = Hashtbl.create 16
|
|
|
|
(* Print-to-current-output function, used everywhere. It has
|
|
* printf-like semantics.
|
|
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
|
|
index c9ef3b0c8..81f2cd6fe 100644
|
|
--- a/generator/tests_c_api.ml
|
|
+++ b/generator/tests_c_api.ml
|
|
@@ -64,7 +64,7 @@ let rec generate_c_api_tests () =
|
|
pr " size_t i;\n";
|
|
pr " const char *no_tests[] = {\n";
|
|
|
|
- let hash : (string, bool) Hashtbl.t = Hashtbl.create 13 in
|
|
+ let hash : (string, bool) Hashtbl.t = Hashtbl.create 16 in
|
|
List.iter (
|
|
fun { tests } ->
|
|
let seqs = List.filter_map (
|
|
diff --git a/generator/utils.ml b/generator/utils.ml
|
|
index 88d8899b5..44b7c7d42 100644
|
|
--- a/generator/utils.ml
|
|
+++ b/generator/utils.ml
|
|
@@ -109,7 +109,7 @@ let rstructs_used_by functions =
|
|
| RStructListOnly, RStructListOnly -> RStructListOnly
|
|
in
|
|
|
|
- let h = Hashtbl.create 13 in
|
|
+ let h = Hashtbl.create 16 in
|
|
|
|
(* if elem->oldv exists, update entry using ||| operator,
|
|
* else just add elem->newv to the hash
|
|
--
|
|
2.47.1
|
|
|