From d0e6b914dbd4b2079ad81d02ba7659f89fe95104 Mon Sep 17 00:00:00 2001 From: xgfone Date: Sat, 24 Aug 2019 17:19:09 +0800 Subject: [PATCH] optimize Traverse to avoid fixing the option name twice --- config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index 65c2f60..8b3310a 100644 --- a/config.go +++ b/config.go @@ -337,7 +337,8 @@ func (c *Config) PrintGroup(w io.Writer) error { func (c *Config) Traverse(f func(group string, opt string, value interface{})) { for _, group := range c.AllGroups() { for _, opt := range group.AllOpts() { - f(group.Name(), group.fixOptName(opt.Name), group.Get(opt.Name)) + name := group.fixOptName(opt.Name) + f(group.Name(), name, group.Get(name)) } } }