pkg/ruler/rulestore/configdb: Preallocate memory (#7326)

Preallocate memory instead of enforcing an incremental growth. This will
result in less work for the garbage collector.
pull/7329/head
Florian Lehner 3 years ago committed by GitHub
parent b23687ad96
commit 4861914c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      pkg/ruler/rulestore/configdb/store.go

@ -36,8 +36,7 @@ func NewConfigRuleStore(c client.Client) *ConfigRuleStore {
func (c *ConfigRuleStore) ListAllUsers(ctx context.Context) ([]string, error) {
m, err := c.ListAllRuleGroups(ctx)
// TODO: this should be optimized, if possible.
result := []string(nil)
result := make([]string, 0, len(m))
for u := range m {
result = append(result, u)
}

Loading…
Cancel
Save