[#263] pkg/netmap: Do not allocate nil repeated fields during conversion

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-03-12 15:58:37 +03:00 committed by Alex Vanin
parent 1031f3122e
commit 5a9dd7ab3f
2 changed files with 22 additions and 12 deletions

View file

@ -230,14 +230,16 @@ func (f *Filter) InnerFilters() []*Filter {
)
}
func filtersToV2(fs []*Filter) []*netmap.Filter {
fsV2 := make([]*netmap.Filter, 0, len(fs))
func filtersToV2(fs []*Filter) (fsV2 []*netmap.Filter) {
if fs != nil {
fsV2 = make([]*netmap.Filter, 0, len(fs))
for i := range fs {
fsV2 = append(fsV2, fs[i].ToV2())
for i := range fs {
fsV2 = append(fsV2, fs[i].ToV2())
}
}
return fsV2
return
}
// SetInnerFilters sets list of inner filters.