use structured binding declarations
Shorter. Signed-off-by: Rosen Penev <rosenp@gmail.com>
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;
|
||||
|
Reference in New Issue
Block a user