Skip to content

Commit

Permalink
Cache current config after loading it from disk for the first time
Browse files Browse the repository at this point in the history
Otherwise, it was re-read from file every time CurrentConfig() was accessed.
  • Loading branch information
mislav committed Sep 26, 2015
1 parent 1c6d4b8 commit c23823d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions github/config.go
Expand Up @@ -211,11 +211,18 @@ func configsFile() string {
return configsFile
}

var currentConfig *Config
var configLoadedFrom = ""

func CurrentConfig() *Config {
c := &Config{}
newConfigService().Load(configsFile(), c)
filename := configsFile()
if configLoadedFrom != filename {
currentConfig = &Config{}
newConfigService().Load(filename, currentConfig)
configLoadedFrom = filename
}

return c
return currentConfig
}

func (c *Config) DefaultHost() (host *Host, err error) {
Expand Down

0 comments on commit c23823d

Please sign in to comment.