-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Refactor ValueTransformer
and WBaseWidget
#13853
Conversation
edb85f9
to
3974c37
Compare
26ca2b0
to
abf5fe6
Compare
This is prep for the follow up commit to make it lighter.
This ensures that if a connection is a DisplayConnection then it is also added to the other connections. This improves memory safety as well as usability because it makes it impossible to accidentally set a connection as DisplayConnection that is not tracked by the WBaseWidget.
66aef70
to
3aea4ed
Compare
friendly ping @daschuer |
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.
Two comments for improved readability. The rest is OK. Thank you.
src/util/valuetransformer.cpp
Outdated
argument = pNode->transformInverse(argument); | ||
} | ||
return argument; | ||
return std::accumulate(m_transformers.crbegin(), |
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.
The semantic of std::accumulate
does not fit here:
Computes the sum of the given value ...
https://en.cppreference.com/w/cpp/algorithm/accumulate
In addition a range based loop is much easier to read.
Please adjust transform above as well.
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.
Well, it does a reduce in a well defined order. std::reduce
rearranges the order and would be unsuitable here. IMO it fits perfectly compared to the eyesore that is the reverse for-loop. I will see if I can make it work with a ranges reverse view
and a ranged for loop, but I don't want to revert to the index-based for loop again.
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.
std::ranges::reverse_view
suits. Hopefully old compilers doe not bite us. Else a rbegin()
solution is also fine.
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.
right, so in case reverse_view
doesn't work out, you'd prefer a for-loop over reverse iterators?
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.
No, I would prefer the reverse iterators in that case.
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.
Whoops, suboptimal wording. I was asking whether you prefer
for (auto it = m_transformers.crbegin(); it != m_transformers.crend(); it++) {
// etc
};
instead of the std::accumulate
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.
yeah, so its macOS again... please suggest your preferred alternative.
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.
The first with the reverse iterators. This is IMHO the most describtive version.
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 don't particularly agree because we're now just copy-pasting the std::accumulate
implementation into there, but whatever you prefer...
1baf659
to
13fb48e
Compare
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.
LGTM,
Still working as expected.
Thank you. |
extracted a commit from #13687 and fixed a TODO there (which in turn led to far bigger changes again).