From 91417a339abee1e8cee2268a5a4ce9f66b2f1f0a Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Thu, 15 Jun 2023 14:03:38 +0000 Subject: [PATCH] Removed checker cache optimization. --- checker.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/checker.go b/checker.go index 4540613..cf17830 100644 --- a/checker.go +++ b/checker.go @@ -34,9 +34,6 @@ var makers = map[string]MakeFunc{ "required": makeRequired, } -// checkerCache provides mapping to checker functions for the config. -var checkerCache = map[string]CheckFunc{} - // Register registers the given checker name and the maker function. func Register(name string, maker MakeFunc) { makers[name] = maker @@ -108,20 +105,14 @@ func initCheckers(config string) []CheckFunc { checkers := make([]CheckFunc, len(fields)) for i, field := range fields { - checker, ok := checkerCache[field] - if !ok { - name, params, _ := strings.Cut(field, ":") + name, params, _ := strings.Cut(field, ":") - maker, ok := makers[name] - if !ok { - panic(fmt.Sprintf("checker %s is unkown", name)) - } - - checker = maker(params) - checkerCache[field] = checker + maker, ok := makers[name] + if !ok { + panic(fmt.Sprintf("checker %s is unkown", name)) } - checkers[i] = checker + checkers[i] = maker(params) } return checkers