return by braced init list

shorter

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2021-11-11 02:18:46 -08:00
parent e08c85ae2d
commit 250011f016
14 changed files with 22 additions and 22 deletions

View File

@ -85,15 +85,15 @@ map_fs_to_utf8(Path path_fs) noexcept
{
if (path_fs.IsAbsolute()) {
if (global_instance->storage == nullptr)
return std::string();
return {};
const auto music_dir_fs = global_instance->storage->MapFS("");
if (music_dir_fs.IsNull())
return std::string();
return {};
auto relative = music_dir_fs.Relative(path_fs);
if (relative == nullptr || StringIsEmpty(relative))
return std::string();
return {};
path_fs = Path::FromFS(relative);
}

View File

@ -278,5 +278,5 @@ Directory::Walk(bool recursive, const SongFilter *filter,
LightDirectory
Directory::Export() const noexcept
{
return LightDirectory(GetPath(), mtime);
return {GetPath(), mtime};
}

View File

@ -250,11 +250,11 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server,
{
const SongFilter *filter = selection.filter;
if (selection.filter == nullptr)
return UPnPDirContent();
return {};
const auto searchcaps = server.getSearchCapabilities(handle);
if (searchcaps.empty())
return UPnPDirContent();
return {};
std::string cond;
for (const auto &item : filter->GetItems()) {

View File

@ -34,7 +34,7 @@ UpdateQueueItem
UpdateQueue::Pop() noexcept
{
if (update_queue.empty())
return UpdateQueueItem();
return {};
auto i = std::move(update_queue.front());
update_queue.pop_front();

View File

@ -26,7 +26,7 @@ Path::ToUTF8() const noexcept
try {
return ToUTF8Throw();
} catch (...) {
return std::string();
return {};
}
}

View File

@ -44,7 +44,7 @@ try {
#ifdef HAVE_ICU
const auto u = UCharFromUTF8(src);
if (u.IsNull())
return AllocatedString(src);
return {src};
AllocatedArray<UChar> folded(u.size() * 2U);
@ -54,7 +54,7 @@ try {
U_FOLD_CASE_DEFAULT,
&error_code);
if (folded_length == 0 || error_code != U_ZERO_ERROR)
return AllocatedString(src);
return {src};
folded.SetSize(folded_length);
return UCharToUTF8({folded.begin(), folded.size()});
@ -63,7 +63,7 @@ try {
#error not implemented
#endif
} catch (...) {
return AllocatedString(src);
return {src};
}
#endif /* HAVE_ICU_CASE_FOLD */

View File

@ -152,7 +152,7 @@ IcuConverter::FromUTF8(std::string_view s) const
throw std::runtime_error(fmt::format(FMT_STRING("Failed to convert from Unicode: {}"),
u_errorName(code)));
return AllocatedString({buffer, size_t(target - buffer)});
return {{buffer, size_t(target - buffer)}};
#elif defined(HAVE_ICONV)
return DoConvert(from_utf8, s);

View File

@ -466,9 +466,9 @@ real_song_duration(const DetachedSong &song,
const SongTime end_time = song.GetEndTime();
if (end_time.IsPositive() && end_time < SongTime(decoder_duration))
return SignedSongTime(end_time - start_time);
return {end_time - start_time};
return SignedSongTime(SongTime(decoder_duration) - start_time);
return {SongTime(decoder_duration) - start_time};
}
bool

View File

@ -87,7 +87,7 @@ extm3u_parse_tag(const char *line)
duration = strtol(line, &endptr, 10);
if (endptr[0] != ',')
/* malformed line */
return Tag();
return {};
if (duration < 0)
/* 0 means unknown duration */
@ -97,7 +97,7 @@ extm3u_parse_tag(const char *line)
if (*name == 0 && duration == 0)
/* no information available; don't allocate a tag
object */
return Tag();
return {};
TagBuilder tag;
tag.SetDuration(SignedSongTime::FromS(unsigned(duration)));

View File

@ -75,5 +75,5 @@ DetachedSong::GetDuration() const noexcept
b = SongTime(tag.duration);
}
return SignedSongTime(b - a);
return {b - a};
}

View File

@ -31,5 +31,5 @@ LightSong::GetDuration() const noexcept
b = SongTime(tag.duration);
}
return SignedSongTime(b - a);
return {b - a};
}

View File

@ -128,7 +128,7 @@ StickerDatabase::LoadValue(const char *type, const char *uri, const char *name)
assert(name != nullptr);
if (StringIsEmpty(name))
return std::string();
return {};
BindAll(s, type, uri, name);

View File

@ -303,7 +303,7 @@ CompositeStorage::MapUTF8(std::string_view uri) const noexcept
auto f = FindStorage(uri);
if (f.directory->storage == nullptr)
return std::string();
return {};
return f.directory->storage->MapUTF8(f.uri);
}

View File

@ -94,7 +94,7 @@ uri_remove_auth(const char *uri) noexcept
const char *auth = SkipUriScheme(uri);
if (auth == nullptr)
/* unrecognized URI */
return std::string();
return {};
const char *slash = std::strchr(auth, '/');
if (slash == nullptr)
@ -103,7 +103,7 @@ uri_remove_auth(const char *uri) noexcept
const char *at = (const char *)std::memchr(auth, '@', slash - auth);
if (at == nullptr)
/* no auth info present, do nothing */
return std::string();
return {};
/* duplicate the full URI and then delete the auth
information */