Skip to content

Commit d6f58fb

Browse files
committed
🔥 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.
1 parent 1595d3b commit d6f58fb

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

internal/config/config_type.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func NewBlankConfig() Config {
9999
type fileConfig struct {
100100
ConfigMap
101101
documentRoot *yaml.Node
102-
hosts []*HostConfig
103102
}
104103

105104
func (c *fileConfig) Get(hostname, key string) (string, error) {
@@ -177,23 +176,12 @@ func (c *fileConfig) Write() error {
177176
}
178177

179178
func (c *fileConfig) hostEntries() ([]*HostConfig, error) {
180-
if len(c.hosts) > 0 {
181-
return c.hosts, nil
182-
}
183-
184179
_, hostsEntry, err := c.FindEntry("hosts")
185180
if err != nil {
186181
return nil, fmt.Errorf("could not find hosts config: %w", err)
187182
}
188183

189-
hostConfigs, err := c.parseHosts(hostsEntry)
190-
if err != nil {
191-
return nil, fmt.Errorf("could not parse hosts config: %w", err)
192-
}
193-
194-
c.hosts = hostConfigs
195-
196-
return hostConfigs, nil
184+
return c.parseHosts(hostsEntry)
197185
}
198186

199187
func (c *fileConfig) makeConfigForHost(hostname string) *HostConfig {

0 commit comments

Comments
 (0)