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

deduplicate identical tags (same tag type and value) #2

Closed
wants to merge 1 commit into from

Conversation

repomaa
Copy link

@repomaa repomaa commented Feb 28, 2016

this fixes problems with duplicate values for track/tracknumber, disc/discnumber etc. without side effects.

@bastelfreak
Copy link

👍

@carnager
Copy link
Contributor

oh seems to be exactly what I requested once 👍

@zeltak
Copy link

zeltak commented Feb 28, 2016

+1

@MaxKellermann
Copy link
Member

This adds overhead by making this O(n^2). If you don't want duplicate tag values, don't store duplicate tag values in the file. MPD is the wrong place to fix this up. Fix your files instead of adding kludges to MPD.

@repomaa
Copy link
Author

repomaa commented Mar 1, 2016

I think you need to see the overhead in context: it adds overhead only if you actually have multiple values for a tag and even then only on db updates.

@repomaa
Copy link
Author

repomaa commented Mar 1, 2016

It's a very small change, and I agree that one shouldn't store duplicate tag values but sometimes you don't have a choice (mpd not being the only player accessing the library etc.) I really don't see the performance as an issue. And if it's not an issue i don't see why this shouldn't just be merged and be done with it. It would solve so many problems.

@repomaa
Copy link
Author

repomaa commented Mar 1, 2016

how would you feel about using std::set instead of std::vector for the values then? This would have the complexity of O(log(n))

@MaxKellermann
Copy link
Member

it adds overhead only if you actually have multiple values for a tag

Completely not true. Your code walks the whole tag item list for each new item.

and even then only on db updates

Also not true. This happens every time a Tag object gets assembled. That happens during database updates, during MPD startup while loading the database, and when a song/stream gets played.

how would you feel about using std::set instead of std::vector for the values then? This would have the complexity of O(log(n))

This adds even more overhead. The complexity is smaller, but the constant factor is a lot bigger.

And it's still the wrong place to do it. MPD reads the tags as-is, and if the tags are wrong, you see wrong tags - if there are duplicate tags, you'll see duplicate tags. Fix them. No lame excuses.

@repomaa
Copy link
Author

repomaa commented Mar 1, 2016

it adds overhead only if you actually have multiple values for a tag

Completely not true. Your code walks the whole tag item list for each new item.

The whole tag item list being one element long in 99.9% of the cases. I'd say that's neglegtable performance wise. Your only reason for not merging is being unwilling to fix problems that don't have their roots in mpd per se. I understand your position, but I honestly fail to see any harm in fixing a problem many mpd users experience when there are virtually no downsides.

I'd say most if not all CSV-parsers support using other separators than , for example even though that's not real CSV. Same thing.

MPD reads the tags as-is, and if the tags are wrong, you see wrong tags - if there are duplicate tags, you'll see duplicate tags.
This is not true. You're already ignoring "album artist" tags for example.

@repomaa
Copy link
Author

repomaa commented Mar 1, 2016

I'm happy to provide benchmarks to prove my point if that will persuade you.

@MaxKellermann
Copy link
Member

No, I'm not interested at all. Let's stop discussing this.

@MusicPlayerDaemon MusicPlayerDaemon locked and limited conversation to collaborators Mar 1, 2016
Rio6 pushed a commit to Rio6/MPD that referenced this pull request Oct 19, 2020
Rio6 pushed a commit to Rio6/MPD that referenced this pull request Oct 30, 2020
Rio6 pushed a commit to Rio6/MPD that referenced this pull request Nov 7, 2020
Rio6 pushed a commit to Rio6/MPD that referenced this pull request Nov 15, 2020
Rio6 pushed a commit to Rio6/MPD that referenced this pull request Nov 23, 2020
Rio6 pushed a commit to Rio6/MPD that referenced this pull request May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants