Merge branch 'struc' of git://github.com/neheb/MPD
This commit is contained in:
@@ -57,9 +57,9 @@ Print(Response &r, TagType group, const TagCountMap &m) noexcept
|
||||
{
|
||||
assert(unsigned(group) < TAG_NUM_OF_ITEM_TYPES);
|
||||
|
||||
for (const auto &i : m) {
|
||||
tag_print(r, group, i.first.c_str());
|
||||
PrintSearchStats(r, i.second);
|
||||
for (const auto &[tag, stats] : m) {
|
||||
tag_print(r, group, tag.c_str());
|
||||
PrintSearchStats(r, stats);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ stats_visitor_song(SearchStats &stats, const LightSong &song) noexcept
|
||||
{
|
||||
stats.n_songs++;
|
||||
|
||||
const auto duration = song.GetDuration();
|
||||
if (!duration.IsNegative())
|
||||
if (const auto duration = song.GetDuration(); !duration.IsNegative())
|
||||
stats.total_duration += duration;
|
||||
}
|
||||
|
||||
@@ -77,8 +76,7 @@ static void
|
||||
CollectGroupCounts(TagCountMap &map, const Tag &tag,
|
||||
const char *value) noexcept
|
||||
{
|
||||
auto r = map.insert(std::make_pair(value, SearchStats()));
|
||||
SearchStats &s = r.first->second;
|
||||
auto &s = map.insert(std::make_pair(value, SearchStats())).first->second;
|
||||
++s.n_songs;
|
||||
if (!tag.duration.IsNegative())
|
||||
s.total_duration += tag.duration;
|
||||
|
||||
@@ -195,11 +195,11 @@ PrintUniqueTags(Response &r, ConstBuffer<TagType> tag_types,
|
||||
const char *const name = tag_item_names[tag_types.front()];
|
||||
tag_types.pop_front();
|
||||
|
||||
for (const auto &i : map) {
|
||||
r.Format("%s: %s\n", name, i.first.c_str());
|
||||
for (const auto &[key, tag] : map) {
|
||||
r.Format("%s: %s\n", name, key.c_str());
|
||||
|
||||
if (!tag_types.empty())
|
||||
PrintUniqueTags(r, tag_types, i.second);
|
||||
PrintUniqueTags(r, tag_types, tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,13 +138,10 @@ Directory::LookupDirectory(std::string_view _uri) noexcept
|
||||
|
||||
Directory *d = this;
|
||||
do {
|
||||
auto s = uri.Split(PathTraitsUTF8::SEPARATOR);
|
||||
if (s.first.empty())
|
||||
auto [name, rest] = uri.Split(PathTraitsUTF8::SEPARATOR);
|
||||
if (name.empty())
|
||||
break;
|
||||
|
||||
const auto name = s.first;
|
||||
const auto rest = s.second;
|
||||
|
||||
Directory *tmp = d->FindChild(name);
|
||||
if (tmp == nullptr)
|
||||
/* not found */
|
||||
|
||||
@@ -427,21 +427,19 @@ UpdateWalk::DirectoryMakeUriParentChecked(Directory &root,
|
||||
StringView uri(_uri);
|
||||
|
||||
while (true) {
|
||||
auto s = uri.Split('/');
|
||||
const std::string_view name = s.first;
|
||||
const auto rest = s.second;
|
||||
auto [name, rest] = uri.Split('/');
|
||||
if (rest == nullptr)
|
||||
break;
|
||||
|
||||
if (!name.empty()) {
|
||||
directory = DirectoryMakeChildChecked(*directory,
|
||||
std::string(name).c_str(),
|
||||
s.first);
|
||||
name);
|
||||
if (directory == nullptr)
|
||||
break;
|
||||
}
|
||||
|
||||
uri = s.second;
|
||||
uri = rest;
|
||||
}
|
||||
|
||||
return directory;
|
||||
|
||||
Reference in New Issue
Block a user