Skip to content

Commit

Permalink
TagAny, playlist/Mapper: use if with initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed May 15, 2024
1 parent a701da6 commit 4e7b554
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
15 changes: 5 additions & 10 deletions src/TagAny.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions src/playlist/PlaylistMapper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4e7b554

Please sign in to comment.