-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Remove ValueBuffer
#7297
base: master
Are you sure you want to change the base?
Remove ValueBuffer
#7297
Conversation
@sakertooth's comment at #7170 (comment) still applies. While passing a pointer to a Also, having thought about it some more, I wonder if we can repurpose it in some way to avoid the endless repeating of code like |
I've addressed this one a week ago and am waiting for a follow up review.
we could but how exactly? I guess we have to write a simple helper function for 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 would add a member function valueAt
to AutomatableModel
that takes an index
as a parameter. It will check if the buffer is not nullptr
, if it is not, then it accesses the buffer at the given index. If it is, then it will use the fixed value and return the result of AutomatableModel::value
. My review is based on assuming this function was added.
(In AutomatableModel.cpp somewhere):
float AutomatableModel::valueAt(size_t index)
{
const auto buffer = valueBuffer();
return buffer ? buffer->data[index] : value();
}
Once you end up replacing calls from value
to valueAt
, make sure to keep the overall expression the same and just change the value
part.
NB: Since AutomatableModel::valueBuffer
seems to be a non-trivial function, it might be worthwhile to see if there's any performance impact after applying these changes since it will be called more frequently.
If what i understand is right, you are asking me to create a helper function to handle the code repetition and modify the code accordingly. But i see one problem in the helper function. float AutomatableModel::valueAt(size_t index)
{
const auto buffer = valueBuffer();
return buffer ? buffer->data[index] : value();
} We create a new buffer and check for the buffer immediately. Which might return true in all cases, so the fixed value might not get accessed. Also the new buffer might have a value different from the old one. Atleast that's what i understand. Is there anything else going on which I missed? |
include/AutomatableModel.h
Outdated
const auto buffer = valueBuffer(); | ||
if (!buffer) { return value(frameOffset); } | ||
|
||
assert(0 < index < buffer->size()); |
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.
@messmerd I did apply assert like you said before but i can't find the thread where you said to apply the assert. Can you cross paste the reference you pasted there?
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This reverts commit 9718dde.
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
@@ -435,6 +435,14 @@ template <typename T> class LMMS_EXPORT TypedAutomatableModel : public Automatab | |||
return AutomatableModel::value<T>( frameOffset ); | |||
} | |||
|
|||
T valueAt(size_t index) |
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 am seriously thinking of removing this function and revert back to the state where everything was working. I did try something now. I'll see anyway.
Looking at this now, I realized it would be better to redesign the sample-exactness system rather than just remove |
supersedes #7170 which got closed because of a mess up on @Snowiiii's side. I recovered their commits using
git fetch upstream pull/7170/head:valuebuffer-removal
.Copied description from original PR.