summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-10-22 09:34:13 +0200
committerMax Kellermann <max@duempel.org>2015-10-22 09:34:13 +0200
commit1a5b66b78dc767a4e0b721a2325957fa9ae815c2 (patch)
tree1d48b059ad7488ed76f1517ff92c32683a4bcb81 /src
parentbea5973e0cffe983584484ad29f900044b003093 (diff)
SongLoader: move code to LoadFromDatabase()
Avoids the recursion in LoadFile().
Diffstat (limited to 'src')
-rw-r--r--src/SongLoader.cxx27
-rw-r--r--src/SongLoader.hxx3
2 files changed, 20 insertions, 10 deletions
diff --git a/src/SongLoader.cxx b/src/SongLoader.cxx
index 5ea8df80c..9f7359a31 100644
--- a/src/SongLoader.cxx
+++ b/src/SongLoader.cxx
@@ -42,6 +42,21 @@ SongLoader::SongLoader(const Client &_client)
#endif
DetachedSong *
+SongLoader::LoadFromDatabase(const char *uri, Error &error) const
+{
+#ifdef ENABLE_DATABASE
+ if (db != nullptr)
+ return DatabaseDetachSong(*db, *storage, uri, error);
+#else
+ (void)uri;
+#endif
+
+ error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
+ "No database");
+ return nullptr;
+}
+
+DetachedSong *
SongLoader::LoadFile(const char *path_utf8, Error &error) const
{
#ifdef ENABLE_DATABASE
@@ -50,7 +65,7 @@ SongLoader::LoadFile(const char *path_utf8, Error &error) const
if (suffix != nullptr)
/* this path was relative to the music
directory - obtain it from the database */
- return LoadSong(suffix, error);
+ return LoadFromDatabase(suffix, error);
}
#endif
@@ -99,14 +114,6 @@ SongLoader::LoadSong(const char *uri_utf8, Error &error) const
} else {
/* URI relative to the music directory */
-#ifdef ENABLE_DATABASE
- if (db != nullptr)
- return DatabaseDetachSong(*db, *storage,
- uri_utf8, error);
-#endif
-
- error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
- "No database");
- return nullptr;
+ return LoadFromDatabase(uri_utf8, error);
}
}
diff --git a/src/SongLoader.hxx b/src/SongLoader.hxx
index 73f9b1f7b..33baa6953 100644
--- a/src/SongLoader.hxx
+++ b/src/SongLoader.hxx
@@ -71,6 +71,9 @@ public:
private:
gcc_nonnull_all
+ DetachedSong *LoadFromDatabase(const char *uri, Error &error) const;
+
+ gcc_nonnull_all
DetachedSong *LoadFile(const char *path_utf8, Error &error) const;
};