-
-
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
iTunes: Share common import logic between XML and macOS #11500
Conversation
This includes the database access, duplicate resolution and keeping track of the playlist tree.
These are parsed from strings in the XML and may be empty
This refactoring makes sense at first glance. I'll try to conduct a proper review in the near future. I'd suggest to call |
In the meantime, can you fix the clazy warnings? |
In that case it should probably be |
...to simplify testing in the future.
Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
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.
Thank you, LGTM otherwise. I highly appreciate these refactoring PRs, even though they're probably in quite unused code.
virtual bool importTrack(const ITunesTrack& track); | ||
virtual bool importPlaylist(const ITunesPlaylist& playlist); |
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 like the fact that these have to be virtual just in order to be tested. Is there no feature in gtest that can avoid that using some linker hacks?
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've thought about this and the other option would be to use templates and parameterize the importer over the DAO. Unfortunately, that would also mean that we'd have to move the implementation into headers etc.
Since virtual methods are generally not thaat expensive (I've tested it on a library with hundreds of playlists and >10k tracks with pretty much no noticeable performance difference), I think this should be fine. The database calls are likely more an order of magnitude more expensive than the virtual function calls.
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, in the scope of everything else, those virtual calls are probably going to be cheap, I'm just used to them being expensive in the context of cache latency and branch prediction.
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, though I didn't conduct any manual tests
This factors out the common, non-format-dependent logic between the iTunes importers into a new class
ITunesDAO
(feel free to suggest a better name), namelyThis means that the iTunes XML importer will now display the playlist folder hierarchy as a tree too!
Architecture
While the new architecture might seem a bit verbose, we get a cleaner separation of concerns and can reduce the platform-specific code, which especially in the case of the macOS importer may improve maintainability too.