From afb7168a6414bd7d5a36ea5668df0170441ee3b1 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 30 Jul 2021 13:25:37 +0300 Subject: [PATCH] hash: move dummy map initialisation into an `fn init(){}`, so users do not have to do it explicitly to be compatible with -skip-unused --- cmd/tools/bench/wyhash.v | 3 --- cmd/tools/vwipe-cache.v | 3 --- vlib/hash/wyhash.c.v | 6 ++++++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/tools/bench/wyhash.v b/cmd/tools/bench/wyhash.v index 10d7e6b0d..b760ad6b5 100644 --- a/cmd/tools/bench/wyhash.v +++ b/cmd/tools/bench/wyhash.v @@ -6,9 +6,6 @@ import rand import benchmark fn main() { - _ := map{ - 1: 1 - } rand.seed([u32(42), 0]) sample_size := 10000000 min_str_len := 20 diff --git a/cmd/tools/vwipe-cache.v b/cmd/tools/vwipe-cache.v index 0715ee070..988b7c262 100644 --- a/cmd/tools/vwipe-cache.v +++ b/cmd/tools/vwipe-cache.v @@ -4,9 +4,6 @@ import os import v.vcache fn main() { - _ := map{ - 1: 1 - } mut cm := vcache.new_cache_manager([]) cpath := cm.basepath if os.exists(cpath) && os.is_dir(cpath) { diff --git a/vlib/hash/wyhash.c.v b/vlib/hash/wyhash.c.v index 4d4efe308..758af0306 100644 --- a/vlib/hash/wyhash.c.v +++ b/vlib/hash/wyhash.c.v @@ -6,6 +6,12 @@ fn C.wyhash(&byte, u64, u64, &u64) u64 fn C.wyhash64(u64, u64) u64 +fn init() { + _ := map{ + 1: 1 + } +} + [inline] pub fn wyhash_c(key &byte, len u64, seed u64) u64 { return C.wyhash(key, len, seed, &u64(C._wyp)) -- 2.30.2