From d6f58fb448f5b79abd6c6c88c4088723d0fc49f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 27 May 2020 22:19:47 +0200 Subject: [PATCH] :fire: hosts optimization We dynamically add hosts on `Set`, so this `hosts` cache might fall out of date. We could ensure to keep it updated, but I'm not convinced it's necessary for speed right now. --- internal/config/config_type.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/config/config_type.go b/internal/config/config_type.go index 4c38c421c..b45ca554b 100644 --- a/internal/config/config_type.go +++ b/internal/config/config_type.go @@ -99,7 +99,6 @@ func NewBlankConfig() Config { type fileConfig struct { ConfigMap documentRoot *yaml.Node - hosts []*HostConfig } func (c *fileConfig) Get(hostname, key string) (string, error) { @@ -177,23 +176,12 @@ func (c *fileConfig) Write() error { } func (c *fileConfig) hostEntries() ([]*HostConfig, error) { - if len(c.hosts) > 0 { - return c.hosts, nil - } - _, hostsEntry, err := c.FindEntry("hosts") if err != nil { return nil, fmt.Errorf("could not find hosts config: %w", err) } - hostConfigs, err := c.parseHosts(hostsEntry) - if err != nil { - return nil, fmt.Errorf("could not parse hosts config: %w", err) - } - - c.hosts = hostConfigs - - return hostConfigs, nil + return c.parseHosts(hostsEntry) } func (c *fileConfig) makeConfigForHost(hostname string) *HostConfig {