fix(boltdb): remove extra allocation and copy from GetObject() EE-5622 (#9111)

pull/9114/head
andres-portainer 1 year ago committed by GitHub
parent 716c196682
commit b12e1aade4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,10 +28,7 @@ func (tx *DbTransaction) GetObject(bucketName string, key []byte, object interfa
return fmt.Errorf("%w (bucket=%s, key=%s)", dserrors.ErrObjectNotFound, bucketName, keyToString(key)) return fmt.Errorf("%w (bucket=%s, key=%s)", dserrors.ErrObjectNotFound, bucketName, keyToString(key))
} }
data := make([]byte, len(value)) return tx.conn.UnmarshalObjectWithJsoniter(value, object)
copy(data, value)
return tx.conn.UnmarshalObjectWithJsoniter(data, object)
} }
func (tx *DbTransaction) UpdateObject(bucketName string, key []byte, object interface{}) error { func (tx *DbTransaction) UpdateObject(bucketName string, key []byte, object interface{}) error {

Loading…
Cancel
Save