[#376] netmap: Make attributes a non-pointer slice

The speed of copying (which is done regulary for e.g. subnet changes)
is less, however it isn't on the hot path and the absolute time
difference is insignificant.
```
name              old time/op    new time/op    delta
NodeAttributes-8    96.2ns ± 1%   158.3ns ± 1%  +64.61%  (p=0.000 n=10+10)

name              old alloc/op   new alloc/op   delta
NodeAttributes-8     32.0B ± 0%     32.0B ± 0%     ~     (all equal)

name              old allocs/op  new allocs/op  delta
NodeAttributes-8      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
```

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-02 10:40:22 +03:00 committed by Alex Vanin
parent 2f0eee96fc
commit 6f4908edc2
6 changed files with 82 additions and 40 deletions

View file

@ -383,7 +383,7 @@ func (ni *NodeInfo) StableMarshal(buf []byte) ([]byte, error) {
offset += n
for i := range ni.attributes {
n, err = protoutil.NestedStructureMarshal(attributesNodeInfoField, buf[offset:], ni.attributes[i])
n, err = protoutil.NestedStructureMarshal(attributesNodeInfoField, buf[offset:], &ni.attributes[i])
if err != nil {
return nil, err
}
@ -408,7 +408,7 @@ func (ni *NodeInfo) StableSize() (size int) {
size += protoutil.RepeatedStringSize(addressNodeInfoField, ni.addresses)
for i := range ni.attributes {
size += protoutil.NestedStructureSize(attributesNodeInfoField, ni.attributes[i])
size += protoutil.NestedStructureSize(attributesNodeInfoField, &ni.attributes[i])
}
size += protoutil.EnumSize(stateNodeInfoField, int32(ni.state))