-
Notifications
You must be signed in to change notification settings - Fork 89
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: growable buffer move_to method #2178
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.
I've always been a little confused about what std::move
does. It seems pretty clear (in this example and others) that it copies data.
What's the difference between this new move_to
function and the old concatenate_to
function? Don't they both copy the panel data into an externally provided buffer and delete the panels?
I'm fine with making these changes (you can merge it when you're happy with it). I'm just asking.
@@ -408,6 +414,7 @@ namespace awkward { | |||
panel_ = std::move(std::unique_ptr<Panel<PRIMITIVE>>( | |||
new Panel<PRIMITIVE>((size_t)options_.initial()))); | |||
ptr_ = panel_.get(); | |||
length_ = 0; | |||
} |
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.
This looks like a bug-fix. Is it?
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've always been a little confused about what std::move does. It seems pretty clear (in this example and others) that it copies data.
I can chime in here! std::move
just indicates to the compiler that the argument can be moved from, i.e. a consumer of the std::move(...)
could avoid a copy by moving from the argument. So, it doesn't always eliminate a copy, depending upon how it is consumed. It's just a signal of lifetime intent IIRC.
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.
This looks like a bug-fix. Is it?
Yes, it is.
The
|
It would be nice if there were only one method. That way, developers don't have to guess which one to use. Separating the functions of "copy the data out into a contiguous buffer" and "remove the panels" would keep more use-cases open. Maybe there's reason to clear the panels without copying out the data (user initiates a reset), and maybe there's a reason to copy the data out and keep filling (the original "snapshot" idea). If |
move_to
method implementation and testclear
method bug fix