Skip to content

Commit

Permalink
pkg/ruler/rulestore/configdb: Preallocate memory (grafana#7326)
Browse files Browse the repository at this point in the history
Preallocate memory instead of enforcing an incremental growth. This will
result in less work for the garbage collector.
  • Loading branch information
florianl authored and Abuelodelanada committed Dec 1, 2022
1 parent 74e64f0 commit 8e816d9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/ruler/rulestore/configdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 8e816d9

Please sign in to comment.