use structured binding declarations

Shorter.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev
2020-10-22 01:36:13 -07:00
parent bb99cf37e3
commit 0fd2c74a66
15 changed files with 49 additions and 61 deletions

View File

@@ -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;