refact(RhythmBoxFeature): Simplified library detection#15825
refact(RhythmBoxFeature): Simplified library detection#15825DidierMalenfant wants to merge 2 commits intomixxxdj:2.6from
Conversation
Unified the method used to detect the library behind maybeDatabaseFilePath() and playlists behind maybePlaylistsFilePath() to make sure code wouldn't be duplicated.
|
Mmmm... |
|
This is a GitHub issue. I have started the build again. Hopefully it fixes the issue. |
There was a problem hiding this comment.
This is unfortunately not ideal in terms of disk access. It is probably not really relevant performance wise, but let's not introduce this regression here. Make sure that exists() is only called once per possible path.
If you like, you can even improve that further:
The pattern:
QFile db(db_path);
mixxx::FileInfo fileInfo(db);
if (!Sandbox::askForAccess(&fileInfo) ||
!db.open(QIODevice::ReadOnly)) {
used in may places is not ideal, because
Only QFile::fileName() is used to create QFileInfo:
But this comes from the internal file engine which is all set up in the QFile() ctor before we have access.
askForAccess() also calls "exists()" you may rely on this or reuse th cached result in a QFileInfo object used earlier for finding the correct path. See:
Line 111 in d93a2fe
Btw: we prefer asignment initalizers when possible:
auto db = QFile(db_path); over QFile db(db_path);
because it does not look like a function call when you skim through the code.
Are you ok with using |
|
I do not understand how an optional type will help but I have no objections if it does. This is anyway no bottleneck. My idea was like that:
The FileInfo object does the caching. |
The optional would be to make the It looks like we can store a default-constructed Internally in |
|
Ah yes, I think I got it. You want even avoid double look ups later. The idea to wrap FileInfo into an std::optional member will even avoid construction of default FileInfo() which involves memory allocation. Calling exists() one FileInfo the first time fills All this has probably a not notable performance impact. So decide wise how much effort you like to put into it. My original concern was just about the addition disc access, during one maybeDatabase... call. |
I'm with you. It's not that much more code and I do like elegant and efficient solutions so I'll throw it in. Still getting my footing on how much to diverge from the code already in place sometimes :) |
Unified the method used to detect the library behind maybeDatabaseFilePath() and playlists behind maybePlaylistsFilePath() to make sure code wouldn't be duplicated.
Added support for Rythmbox3 when installed as flatpak