From e68227c8bd104ddb84abd6d433056f57f42df29a Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Thu, 15 Jun 2023 07:05:37 -0700 Subject: [PATCH] Removed checker cache optimization. (#9) --- 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