Tag: add class const_iterator and methods begin(), end()
Enables using range-based "for".
This commit is contained in:
@@ -73,9 +73,7 @@ static bool
|
||||
CollectGroupCounts(TagCountMap &map, TagType group, const Tag &tag)
|
||||
{
|
||||
bool found = false;
|
||||
for (unsigned i = 0; i < tag.num_items; ++i) {
|
||||
const TagItem &item = *tag.items[i];
|
||||
|
||||
for (const auto &item : tag) {
|
||||
if (item.type == group) {
|
||||
auto r = map.insert(std::make_pair(item.value,
|
||||
SearchStats()));
|
||||
|
||||
@@ -184,12 +184,10 @@ PrintUniqueTag(Client &client, TagType tag_type,
|
||||
assert(value != nullptr);
|
||||
client_printf(client, "%s: %s\n", tag_item_names[tag_type], value);
|
||||
|
||||
for (unsigned i = 0, n = tag.num_items; i < n; i++) {
|
||||
const TagItem &item = *tag.items[i];
|
||||
for (const auto &item : tag)
|
||||
if (item.type != tag_type)
|
||||
client_printf(client, "%s: %s\n",
|
||||
tag_item_names[item.type], item.value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,9 +43,7 @@ StatsVisitTag(DatabaseStats &stats, StringSet &artists, StringSet &albums,
|
||||
if (tag.time > 0)
|
||||
stats.total_duration += tag.time;
|
||||
|
||||
for (unsigned i = 0; i < tag.num_items; ++i) {
|
||||
const TagItem &item = *tag.items[i];
|
||||
|
||||
for (const auto &item : tag) {
|
||||
switch (item.type) {
|
||||
case TAG_ARTIST:
|
||||
#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
|
||||
|
||||
Reference in New Issue
Block a user