Skip to content

PlayerManager: Move duplicate code into function in anonymous namespace#4582

Merged
Swiftb0y merged 1 commit into
mixxxdj:mainfrom
Holzhaus:playermanager-deduplicate-nextfreeplayer
Dec 25, 2021
Merged

PlayerManager: Move duplicate code into function in anonymous namespace#4582
Swiftb0y merged 1 commit into
mixxxdj:mainfrom
Holzhaus:playermanager-deduplicate-nextfreeplayer

Conversation

@Holzhaus
Copy link
Copy Markdown
Member

No description provided.

@Holzhaus Holzhaus added this to the 2.4.0 milestone Dec 24, 2021
@Holzhaus Holzhaus force-pushed the playermanager-deduplicate-nextfreeplayer branch from 6dcec20 to 90f60bc Compare December 25, 2021 12:58
/// the corresponding `play` CO is set to 0.
template<class T>
T* findFirstStoppedPlayerInList(const QList<T*>& players) {
for (T* pPlayer : players) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this could be const if BasePlayer::getGroup() was const (which it should be IMO).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean this?

Suggested change
for (T* pPlayer : players) {
for (const T* pPlayer : players) {

This does not work, because in that case the return type would also have to be const. This would severly limit what you can do with the result (or you'd need to use const_cast which I consider a terrible hack).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good point. I didn't think about that. LGTM me then.

@Holzhaus Holzhaus force-pushed the playermanager-deduplicate-nextfreeplayer branch from 90f60bc to d898e5e Compare December 25, 2021 13:22
Copy link
Copy Markdown
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.

Thanks

@Swiftb0y Swiftb0y merged commit ab55358 into mixxxdj:main Dec 25, 2021
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