From 79e33d92f195c74b531a5f457a50b1ed1e0f3075 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 23 Sep 2021 10:12:22 +0300 Subject: [PATCH] v.markused: remove `hash.init()` function (map fn usages are detected more precisely) --- vlib/hash/wyhash.c.v | 6 ------ vlib/v/markused/walker.v | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/vlib/hash/wyhash.c.v b/vlib/hash/wyhash.c.v index 3f93d245d2..9fc4b06c5e 100644 --- a/vlib/hash/wyhash.c.v +++ b/vlib/hash/wyhash.c.v @@ -6,12 +6,6 @@ fn C.wyhash(&byte, u64, u64, &u64) u64 fn C.wyhash64(u64, u64) u64 -fn init() { - _ := { - 1: 1 - } -} - [inline] pub fn wyhash_c(key &byte, len u64, seed u64) u64 { return C.wyhash(key, len, seed, &u64(C._wyp)) diff --git a/vlib/v/markused/walker.v b/vlib/v/markused/walker.v index e835185fe5..6089d44a88 100644 --- a/vlib/v/markused/walker.v +++ b/vlib/v/markused/walker.v @@ -358,6 +358,10 @@ fn (mut w Walker) expr(node ast.Expr) { if ifield.has_default_expr { w.expr(ifield.default_expr) } + fsym := w.table.get_type_symbol(ifield.typ) + if fsym.kind == .map { + w.table.used_maps++ + } } } if node.has_update_expr { @@ -429,6 +433,9 @@ pub fn (mut w Walker) call_expr(mut node ast.CallExpr) { w.expr(arg.expr) } if node.language == .c { + if node.name in ['C.wyhash', 'C.wyhash64'] { + w.table.used_maps++ + } return } w.expr(node.left)