From 4e7b554605f10d5b758c92e853ebb4e8e1ec24c0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 May 2024 14:59:41 +0200 Subject: [PATCH] TagAny, playlist/Mapper: use `if` with initializer --- src/TagAny.cxx | 15 +++++---------- src/playlist/PlaylistMapper.cxx | 7 ++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/TagAny.cxx b/src/TagAny.cxx index e4535ecc4..4ba3dfaee 100644 --- a/src/TagAny.cxx +++ b/src/TagAny.cxx @@ -111,17 +111,12 @@ TagScanDatabase(Client &client, const char *uri, TagHandler &handler) #ifdef ENABLE_DATABASE } - { - const auto path_fs = storage->MapFS(uri); - if (!path_fs.IsNull()) - return TagScanFile(path_fs, handler); - } + if (const auto path_fs = storage->MapFS(uri); !path_fs.IsNull()) + return TagScanFile(path_fs, handler); - { - const auto absolute_uri = storage->MapUTF8(uri); - if (uri_has_scheme(absolute_uri)) - return TagScanStream(absolute_uri.c_str(), handler); - } + if (const auto absolute_uri = storage->MapUTF8(uri); + uri_has_scheme(absolute_uri)) + return TagScanStream(absolute_uri.c_str(), handler); throw ProtocolError(ACK_ERROR_NO_EXIST, "No such file"); #endif diff --git a/src/playlist/PlaylistMapper.cxx b/src/playlist/PlaylistMapper.cxx index 68acd91a7..29f568747 100644 --- a/src/playlist/PlaylistMapper.cxx +++ b/src/playlist/PlaylistMapper.cxx @@ -40,11 +40,8 @@ playlist_open_in_storage(const char *uri, const Storage *storage, Mutex &mutex) if (storage == nullptr) return nullptr; - { - const auto path = storage->MapFS(uri); - if (!path.IsNull()) - return playlist_open_path(path, mutex); - } + if (const auto path = storage->MapFS(uri); !path.IsNull()) + return playlist_open_path(path, mutex); const auto uri2 = storage->MapUTF8(uri); return playlist_open_remote(uri2.c_str(), mutex);