diff options
author | Max Kellermann <max@duempel.org> | 2014-12-12 22:04:43 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-12 22:04:43 +0100 |
commit | 71ece564702a5d91d72f5d35fe34fe5cf9f18556 (patch) | |
tree | 3dd44ebc150149d7796b5ed7bedec9365a7be7c3 /src/sticker | |
parent | 204a1de3fd575deadda595b39799b9b9f6e7564e (diff) | |
download | mpd-71ece564702a5d91d72f5d35fe34fe5cf9f18556.tar.gz mpd-71ece564702a5d91d72f5d35fe34fe5cf9f18556.tar.xz mpd-71ece564702a5d91d72f5d35fe34fe5cf9f18556.zip |
sticker/Database: move code to BindFind()
Diffstat (limited to 'src/sticker')
-rw-r--r-- | src/sticker/StickerDatabase.cxx | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/sticker/StickerDatabase.cxx b/src/sticker/StickerDatabase.cxx index 70f47d163..e1e5d76ab 100644 --- a/src/sticker/StickerDatabase.cxx +++ b/src/sticker/StickerDatabase.cxx @@ -368,6 +368,20 @@ sticker_load(const char *type, const char *uri, Error &error) return new sticker(std::move(s)); } +static sqlite3_stmt * +BindFind(const char *type, const char *base_uri, const char *name, + Error &error) +{ + assert(type != nullptr); + assert(name != nullptr); + + if (base_uri == nullptr) + base_uri = ""; + + return BindAllOrNull(error, sticker_stmt[STICKER_SQL_FIND], + type, base_uri, name); +} + bool sticker_find(const char *type, const char *base_uri, const char *name, void (*func)(const char *uri, const char *value, @@ -375,17 +389,11 @@ sticker_find(const char *type, const char *base_uri, const char *name, void *user_data, Error &error) { - sqlite3_stmt *const stmt = sticker_stmt[STICKER_SQL_FIND]; - - assert(type != nullptr); - assert(name != nullptr); assert(func != nullptr); assert(sticker_enabled()); - if (base_uri == nullptr) - base_uri = ""; - - if (!BindAll(error, stmt, type, base_uri, name)) + sqlite3_stmt *const stmt = BindFind(type, base_uri, name, error); + if (stmt == nullptr) return false; const bool success = ExecuteForEach(stmt, error, |