Skip to content

Commit

Permalink
[chore] [discoverer] Remove redundant memoization (#5330)
Browse files Browse the repository at this point in the history
The is no need to memoize the bundle config because the whole retrieved is memoized. So "<bundle>" key access cannot happen twice
  • Loading branch information
dmitryax authored Sep 9, 2024
1 parent 4358510 commit ee86dbc
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions internal/confmapprovider/discovery/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,13 @@ func (m *Provider) retrieve(scheme string) func(context.Context, string, confmap
if m.retrieved != nil {
return m.retrieved, nil
}
var bundledCfg *Config
if bundledCfg, ok = m.configs["<bundled>"]; !ok {
m.logger.Debug("loading bundle.d")
bundledCfg = NewConfig(m.logger)
if err := bundledCfg.LoadFS(bundle.BundledFS); err != nil {
m.logger.Error("failed loading bundle.d", zap.Error(err))
return nil, err
}
m.logger.Debug("successfully loaded bundle.d")
m.configs["<bundled>"] = bundledCfg
m.logger.Debug("loading bundle.d")
bundledCfg := NewConfig(m.logger)
if err := bundledCfg.LoadFS(bundle.BundledFS); err != nil {
m.logger.Error("failed loading bundle.d", zap.Error(err))
return nil, err
}
m.logger.Debug("successfully loaded bundle.d")
if err := mergeConfigWithBundle(cfg, bundledCfg); err != nil {
return nil, fmt.Errorf("failed merging user and bundled discovery configs: %w", err)
}
Expand Down

0 comments on commit ee86dbc

Please sign in to comment.