[#1523] writecache: Remove cloneBytes

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-07-07 15:56:05 +03:00 committed by fyrchik
parent ddaed283e9
commit 5aa3defc67
2 changed files with 4 additions and 8 deletions

View file

@ -4,6 +4,7 @@ import (
"time" "time"
"github.com/mr-tron/base58" "github.com/mr-tron/base58"
"github.com/nspcc-dev/neo-go/pkg/util/slice"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-sdk-go/object" "github.com/nspcc-dev/neofs-sdk-go/object"
@ -84,7 +85,7 @@ func (c *cache) flush() {
sz += len(k) + len(v) sz += len(k) + len(v)
m = append(m, objectInfo{ m = append(m, objectInfo{
addr: string(k), addr: string(k),
data: cloneBytes(v), data: slice.Copy(v),
}) })
} }
return nil return nil
@ -227,9 +228,3 @@ func (c *cache) flushObject(obj *object.Object) error {
_, err = c.metabase.Put(pPrm) _, err = c.metabase.Put(pPrm)
return err return err
} }
func cloneBytes(a []byte) []byte {
b := make([]byte, len(a))
copy(b, a)
return b
}

View file

@ -1,6 +1,7 @@
package writecache package writecache
import ( import (
"github.com/nspcc-dev/neo-go/pkg/util/slice"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/common"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object" objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
@ -66,7 +67,7 @@ func Get(db *bbolt.DB, key []byte) ([]byte, error) {
return errNotFound return errNotFound
} }
value = cloneBytes(value) value = slice.Copy(value)
return nil return nil
}) })
return value, err return value, err