Skip to content
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

Merged
merged 10 commits into from
Nov 26, 2024

Conversation

Swiftb0y
Copy link
Member

@Swiftb0y Swiftb0y commented Nov 8, 2024

extracted a commit from #13687 and fixed a TODO there (which in turn led to far bigger changes again).

src/skin/legacy/legacyskinparser.cpp Outdated Show resolved Hide resolved
@Swiftb0y Swiftb0y force-pushed the refactor/valuetransformer branch 5 times, most recently from 26ca2b0 to abf5fe6 Compare November 13, 2024 18:03
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.
@Swiftb0y
Copy link
Member Author

friendly ping @daschuer

Copy link
Member

@daschuer daschuer left a 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.

argument = pNode->transformInverse(argument);
}
return argument;
return std::accumulate(m_transformers.crbegin(),
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

@Swiftb0y Swiftb0y Nov 23, 2024

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

Copy link
Member Author

@Swiftb0y Swiftb0y Nov 23, 2024

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.

Copy link
Member

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.

Copy link
Member Author

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...

src/util/valuetransformer.cpp Outdated Show resolved Hide resolved
Copy link
Member

@daschuer daschuer left a 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.

@daschuer daschuer merged commit 0eccb1b into mixxxdj:main Nov 26, 2024
13 checks passed
@Swiftb0y Swiftb0y deleted the refactor/valuetransformer branch November 27, 2024 09:04
@Swiftb0y
Copy link
Member Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants