Perfomance: Preallocate slices (#61580)

This commit is contained in:
Denis Limarev
2023-01-17 17:50:17 +06:00
committed by GitHub
parent d2a5b9b289
commit e6dee8a723
13 changed files with 20 additions and 17 deletions

View File

@@ -190,7 +190,7 @@ func (kv *SecretsKVStorePlugin) WithFallbackEnabled(fn func() error) error {
}
func parseKeys(keys []*smp.Key) []Key {
var newKeys []Key
newKeys := make([]Key, 0, len(keys))
for _, k := range keys {
newKey := Key{OrgId: k.OrgId, Namespace: k.Namespace, Type: k.Type}
@@ -201,7 +201,7 @@ func parseKeys(keys []*smp.Key) []Key {
}
func parseItems(items []*smp.Item) []Item {
var newItems []Item
newItems := make([]Item, 0, len(items))
for _, i := range items {
newItem := Item{OrgId: &i.Key.OrgId, Namespace: &i.Key.Namespace, Type: &i.Key.Type, Value: i.Value}