-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CopyTo method for deep copy #512
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about object.Object
?
e01dc3c
to
60101e0
Compare
I wasn't confident about it. But added it now |
499e44c
to
f5d679a
Compare
return | ||
} | ||
|
||
id := (*object.Object)(&o).GetObjectID() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
, sig
and header
have reference fields, why don't we deep copy them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, Now we have a monster inside SDK.
I tend to think we should implement this CopyTo
inside api-go lib, because SDK in many cases uses types from it. Not for all types, but for most frequently used in SDK. For instance, take from this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create an issue for api-go, but for now we need some way to handle this in SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e5f5668
to
2807cdd
Compare
return | ||
} | ||
|
||
id := (*object.Object)(&o).GetObjectID() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create an issue for api-go, but for now we need some way to handle this in SDK.
2807cdd
to
5bb7572
Compare
5bb7572
to
08dffcd
Compare
Signed-off-by: Evgenii Baidakov <[email protected]>
Signed-off-by: Evgenii Baidakov <[email protected]>
Signed-off-by: Evgenii Baidakov <[email protected]>
Signed-off-by: Evgenii Baidakov <[email protected]>
closes #194 Signed-off-by: Evgenii Baidakov <[email protected]>
08dffcd
to
731030a
Compare
v2session "github.com/nspcc-dev/neofs-api-go/v2/session" | ||
) | ||
|
||
func copyByteSlice(sl []byte) []byte { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you copy a slice of something more than once, how about 😎generic😎 copySlice
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave it for 1.21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with 1.21 it is even better and (if my suggestion is applied) could be fixed with sed
(the current version will require more work). also, that is just more boilerplate code
not critical for me
BTW, I am not sure dropping deep copy method for the structs that do not need it for now is a must. If it had been already done I wouldn't have dropped it. Looks like a good practice to provide |
closes #194