return by braced init list
shorter Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
e08c85ae2d
commit
250011f016
@ -85,15 +85,15 @@ map_fs_to_utf8(Path path_fs) noexcept
|
|||||||
{
|
{
|
||||||
if (path_fs.IsAbsolute()) {
|
if (path_fs.IsAbsolute()) {
|
||||||
if (global_instance->storage == nullptr)
|
if (global_instance->storage == nullptr)
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
const auto music_dir_fs = global_instance->storage->MapFS("");
|
const auto music_dir_fs = global_instance->storage->MapFS("");
|
||||||
if (music_dir_fs.IsNull())
|
if (music_dir_fs.IsNull())
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
auto relative = music_dir_fs.Relative(path_fs);
|
auto relative = music_dir_fs.Relative(path_fs);
|
||||||
if (relative == nullptr || StringIsEmpty(relative))
|
if (relative == nullptr || StringIsEmpty(relative))
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
path_fs = Path::FromFS(relative);
|
path_fs = Path::FromFS(relative);
|
||||||
}
|
}
|
||||||
|
@ -278,5 +278,5 @@ Directory::Walk(bool recursive, const SongFilter *filter,
|
|||||||
LightDirectory
|
LightDirectory
|
||||||
Directory::Export() const noexcept
|
Directory::Export() const noexcept
|
||||||
{
|
{
|
||||||
return LightDirectory(GetPath(), mtime);
|
return {GetPath(), mtime};
|
||||||
}
|
}
|
||||||
|
@ -250,11 +250,11 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server,
|
|||||||
{
|
{
|
||||||
const SongFilter *filter = selection.filter;
|
const SongFilter *filter = selection.filter;
|
||||||
if (selection.filter == nullptr)
|
if (selection.filter == nullptr)
|
||||||
return UPnPDirContent();
|
return {};
|
||||||
|
|
||||||
const auto searchcaps = server.getSearchCapabilities(handle);
|
const auto searchcaps = server.getSearchCapabilities(handle);
|
||||||
if (searchcaps.empty())
|
if (searchcaps.empty())
|
||||||
return UPnPDirContent();
|
return {};
|
||||||
|
|
||||||
std::string cond;
|
std::string cond;
|
||||||
for (const auto &item : filter->GetItems()) {
|
for (const auto &item : filter->GetItems()) {
|
||||||
|
@ -34,7 +34,7 @@ UpdateQueueItem
|
|||||||
UpdateQueue::Pop() noexcept
|
UpdateQueue::Pop() noexcept
|
||||||
{
|
{
|
||||||
if (update_queue.empty())
|
if (update_queue.empty())
|
||||||
return UpdateQueueItem();
|
return {};
|
||||||
|
|
||||||
auto i = std::move(update_queue.front());
|
auto i = std::move(update_queue.front());
|
||||||
update_queue.pop_front();
|
update_queue.pop_front();
|
||||||
|
@ -26,7 +26,7 @@ Path::ToUTF8() const noexcept
|
|||||||
try {
|
try {
|
||||||
return ToUTF8Throw();
|
return ToUTF8Throw();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return std::string();
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ try {
|
|||||||
#ifdef HAVE_ICU
|
#ifdef HAVE_ICU
|
||||||
const auto u = UCharFromUTF8(src);
|
const auto u = UCharFromUTF8(src);
|
||||||
if (u.IsNull())
|
if (u.IsNull())
|
||||||
return AllocatedString(src);
|
return {src};
|
||||||
|
|
||||||
AllocatedArray<UChar> folded(u.size() * 2U);
|
AllocatedArray<UChar> folded(u.size() * 2U);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ try {
|
|||||||
U_FOLD_CASE_DEFAULT,
|
U_FOLD_CASE_DEFAULT,
|
||||||
&error_code);
|
&error_code);
|
||||||
if (folded_length == 0 || error_code != U_ZERO_ERROR)
|
if (folded_length == 0 || error_code != U_ZERO_ERROR)
|
||||||
return AllocatedString(src);
|
return {src};
|
||||||
|
|
||||||
folded.SetSize(folded_length);
|
folded.SetSize(folded_length);
|
||||||
return UCharToUTF8({folded.begin(), folded.size()});
|
return UCharToUTF8({folded.begin(), folded.size()});
|
||||||
@ -63,7 +63,7 @@ try {
|
|||||||
#error not implemented
|
#error not implemented
|
||||||
#endif
|
#endif
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
return AllocatedString(src);
|
return {src};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_ICU_CASE_FOLD */
|
#endif /* HAVE_ICU_CASE_FOLD */
|
||||||
|
@ -152,7 +152,7 @@ IcuConverter::FromUTF8(std::string_view s) const
|
|||||||
throw std::runtime_error(fmt::format(FMT_STRING("Failed to convert from Unicode: {}"),
|
throw std::runtime_error(fmt::format(FMT_STRING("Failed to convert from Unicode: {}"),
|
||||||
u_errorName(code)));
|
u_errorName(code)));
|
||||||
|
|
||||||
return AllocatedString({buffer, size_t(target - buffer)});
|
return {{buffer, size_t(target - buffer)}};
|
||||||
|
|
||||||
#elif defined(HAVE_ICONV)
|
#elif defined(HAVE_ICONV)
|
||||||
return DoConvert(from_utf8, s);
|
return DoConvert(from_utf8, s);
|
||||||
|
@ -466,9 +466,9 @@ real_song_duration(const DetachedSong &song,
|
|||||||
const SongTime end_time = song.GetEndTime();
|
const SongTime end_time = song.GetEndTime();
|
||||||
|
|
||||||
if (end_time.IsPositive() && end_time < SongTime(decoder_duration))
|
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
|
bool
|
||||||
|
@ -87,7 +87,7 @@ extm3u_parse_tag(const char *line)
|
|||||||
duration = strtol(line, &endptr, 10);
|
duration = strtol(line, &endptr, 10);
|
||||||
if (endptr[0] != ',')
|
if (endptr[0] != ',')
|
||||||
/* malformed line */
|
/* malformed line */
|
||||||
return Tag();
|
return {};
|
||||||
|
|
||||||
if (duration < 0)
|
if (duration < 0)
|
||||||
/* 0 means unknown duration */
|
/* 0 means unknown duration */
|
||||||
@ -97,7 +97,7 @@ extm3u_parse_tag(const char *line)
|
|||||||
if (*name == 0 && duration == 0)
|
if (*name == 0 && duration == 0)
|
||||||
/* no information available; don't allocate a tag
|
/* no information available; don't allocate a tag
|
||||||
object */
|
object */
|
||||||
return Tag();
|
return {};
|
||||||
|
|
||||||
TagBuilder tag;
|
TagBuilder tag;
|
||||||
tag.SetDuration(SignedSongTime::FromS(unsigned(duration)));
|
tag.SetDuration(SignedSongTime::FromS(unsigned(duration)));
|
||||||
|
@ -75,5 +75,5 @@ DetachedSong::GetDuration() const noexcept
|
|||||||
b = SongTime(tag.duration);
|
b = SongTime(tag.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SignedSongTime(b - a);
|
return {b - a};
|
||||||
}
|
}
|
||||||
|
@ -31,5 +31,5 @@ LightSong::GetDuration() const noexcept
|
|||||||
b = SongTime(tag.duration);
|
b = SongTime(tag.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SignedSongTime(b - a);
|
return {b - a};
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ StickerDatabase::LoadValue(const char *type, const char *uri, const char *name)
|
|||||||
assert(name != nullptr);
|
assert(name != nullptr);
|
||||||
|
|
||||||
if (StringIsEmpty(name))
|
if (StringIsEmpty(name))
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
BindAll(s, type, uri, name);
|
BindAll(s, type, uri, name);
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ CompositeStorage::MapUTF8(std::string_view uri) const noexcept
|
|||||||
|
|
||||||
auto f = FindStorage(uri);
|
auto f = FindStorage(uri);
|
||||||
if (f.directory->storage == nullptr)
|
if (f.directory->storage == nullptr)
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
return f.directory->storage->MapUTF8(f.uri);
|
return f.directory->storage->MapUTF8(f.uri);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ uri_remove_auth(const char *uri) noexcept
|
|||||||
const char *auth = SkipUriScheme(uri);
|
const char *auth = SkipUriScheme(uri);
|
||||||
if (auth == nullptr)
|
if (auth == nullptr)
|
||||||
/* unrecognized URI */
|
/* unrecognized URI */
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
const char *slash = std::strchr(auth, '/');
|
const char *slash = std::strchr(auth, '/');
|
||||||
if (slash == nullptr)
|
if (slash == nullptr)
|
||||||
@ -103,7 +103,7 @@ uri_remove_auth(const char *uri) noexcept
|
|||||||
const char *at = (const char *)std::memchr(auth, '@', slash - auth);
|
const char *at = (const char *)std::memchr(auth, '@', slash - auth);
|
||||||
if (at == nullptr)
|
if (at == nullptr)
|
||||||
/* no auth info present, do nothing */
|
/* no auth info present, do nothing */
|
||||||
return std::string();
|
return {};
|
||||||
|
|
||||||
/* duplicate the full URI and then delete the auth
|
/* duplicate the full URI and then delete the auth
|
||||||
information */
|
information */
|
||||||
|
Loading…
Reference in New Issue
Block a user