-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat: a new userData API Remove
#1117
feat: a new userData API Remove
#1117
Conversation
Remove
Why ʼstatusDeletedʼ why not just remove the entry from the slice? |
removing an entry from the slice will migrate other entries following the removed one forward . it causes memory migration. removing an entry logically can avoiding the migration. |
I'm not sure what you mean with memory migration but rearranging the slice isn't a bad thing you can just copy the last entry of the slice to the one that gets deleted and decrease the len by 1. Just make sure to set the |
userdata.go
Outdated
for i := 0; i < n; i++ { | ||
kv := &args[i] | ||
if string(kv.key) == key { | ||
kv.status = statusDeleted |
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.
So here something like:
n--
args[i] = args[n]
args[n].value = nil // Make sure not to keep the value alive for the GC.
args = args[:n]
*d = args
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.
thanks for reviewing, i will change it.
Thanks! |
issue
a new API for deleting a key instead of setting nil.
status
touserDataKV
which report whether theuserDataKV
is deleted or not.