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

Fix clazy issues on main #12028

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Fix clazy issues on main #12028

merged 1 commit into from
Sep 27, 2023

Conversation

Holzhaus
Copy link
Member

No description provided.

@github-actions github-actions bot added ui and removed code quality labels Sep 26, 2023
@Holzhaus Holzhaus added code quality and removed ui labels Sep 26, 2023
@Holzhaus Holzhaus added this to the 2.5.0 milestone Sep 26, 2023
@daschuer
Copy link
Member

It looks like all these improvements also apply to 2.4. Did you consider to retarget this PR to 2.4?

@@ -73,6 +73,7 @@ void WEffectChainPresetButton::populateMenu() {
tooltip.append("<br/>");
tooltip.append(effectNames.join("<br/>"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid join() is also a reallocation in a loop as well as append() above.
Clear() below deletes all QStrings in the QList(), keeping only the space for the data-pointer.
Getting rid of the whole string list would be better or reuse the QStrings in it.

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 agree, feel free to fix this in a follow-up. At least this should fix the failing CI build after we merged 2.4 to main.

@Holzhaus
Copy link
Member Author

It looks like all these improvements also apply to 2.4. Did you consider to retarget this PR to 2.4?

Almost. No idea why the CI on the clazy PR passed though. I opened #12031. This contains a fix which only applies to main.

@Holzhaus Holzhaus marked this pull request as ready for review September 26, 2023 15:30
@github-actions github-actions bot added ui and removed code quality labels Sep 26, 2023
@Holzhaus
Copy link
Member Author

FYI clazy build checks are failing, because #12031 has not been merged yet. But this PR may already be merged independently.

Comment on lines +71 to +72
const auto sampleRates = m_pSoundManager->getSampleRates();
for (const auto& sampleRate : sampleRates) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what warning does this fix? just out of curiosity because I don't see why one would be preferred over the other.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I would've preferred std::as_const(m_pSoundManager->getSampleRates()) instead though, without the extra variable. Otherwise it would make me think that sampleRates is used outside the loop as well. Any reason you decided against that?

Copy link
Member Author

@Holzhaus Holzhaus Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible:

src/preferences/dialog/dlgprefsound.cpp: In constructor ‘DlgPrefSound::DlgPrefSound(QWidget*, std::shared_ptr<SoundManager>, UserSettingsPointer)’:
src/preferences/dialog/dlgprefsound.cpp:71:48: error: use of deleted function ‘void std::as_const(const _Tp&&) [with _Tp = QList<mixxx::audio::SampleRate>]’
   71 |     for (const auto& sampleRate : std::as_const(m_pSoundManager->getSampleRates())) {
      |                                   ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/qt/QtCore/qglobal.h:47,
                 from /usr/include/qt/QtCore/qalgorithms.h:43,
                 from /usr/include/qt/QtCore/qdebug.h:44,
                 from /usr/include/qt/QtCore/QDebug:1,
                 from /home/jan/Projects/mixxx/src/audio/frame.h:3,
                 from /home/jan/Projects/mixxx/build/CMakeFiles/mixxx-lib.dir/cmake_pch.hxx:5,
                 from <command-line>:
/usr/include/c++/13.2.1/utility:112:10: note: declared here
  112 |     void as_const(const _Tp&&) = delete;
      |          ^~~~~~~~
      ```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, of course. thats probably why C++ now supports an init statement...
that has been shot down previously in code review (without good reason IMO) so I'm not suggesting to use it.

    for (const auto sampleRates = m_pSoundManager->getSampleRates(); const auto& sampleRate : sampleRates) {

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. waiting for CI

@JoergAtGithub
Copy link
Member

LGTM! Thank you!

@JoergAtGithub JoergAtGithub merged commit d5dba0d into mixxxdj:main Sep 27, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants