forked from TrueCloudLab/frostfs-node
[#1239] util/attributes: Remove excessive slice copy during parsing
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
2ad8016d75
commit
6936195afa
1 changed files with 4 additions and 9 deletions
|
@ -28,7 +28,7 @@ func ParseV2Attributes(attrs []string, excl []string) ([]netmap.NodeAttribute, e
|
|||
}
|
||||
|
||||
cache := make(map[string]*netmap.NodeAttribute, len(attrs))
|
||||
result := make([]*netmap.NodeAttribute, 0, len(attrs))
|
||||
result := make([]netmap.NodeAttribute, 0, len(attrs))
|
||||
|
||||
for i := range attrs {
|
||||
line := strings.Trim(attrs[i], pairSeparator)
|
||||
|
@ -59,9 +59,9 @@ func ParseV2Attributes(attrs []string, excl []string) ([]netmap.NodeAttribute, e
|
|||
}
|
||||
|
||||
if !present {
|
||||
attribute = netmap.NewNodeAttribute()
|
||||
result = append(result, netmap.NodeAttribute{})
|
||||
attribute = &result[len(result)-1]
|
||||
cache[key] = attribute
|
||||
result = append(result, attribute)
|
||||
|
||||
// replace non-printable symbols with escaped symbols without escape character
|
||||
key = replaceEscaping(key, true)
|
||||
|
@ -82,12 +82,7 @@ func ParseV2Attributes(attrs []string, excl []string) ([]netmap.NodeAttribute, e
|
|||
}
|
||||
}
|
||||
|
||||
nresult := make([]netmap.NodeAttribute, len(result))
|
||||
for i := range result {
|
||||
nresult[i] = *result[i]
|
||||
}
|
||||
|
||||
return nresult, nil
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func replaceEscaping(target string, rollback bool) (s string) {
|
||||
|
|
Loading…
Reference in a new issue