aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-12 17:22:39 +0200
committerMax Kellermann <max@duempel.org>2014-07-12 17:22:39 +0200
commit41a7203c28d2cc7550f1bb05f767950d388326cd (patch)
tree0b0970bbaf06b66ec0c0b3a50d90b3f6ef65dd20 /src/db
parent543a58bb874be8a510d54e91a37797b0c71b1160 (diff)
downloadmpd-41a7203c28d2cc7550f1bb05f767950d388326cd.tar.gz
mpd-41a7203c28d2cc7550f1bb05f767950d388326cd.tar.xz
mpd-41a7203c28d2cc7550f1bb05f767950d388326cd.zip
Tag: add class const_iterator and methods begin(), end()
Enables using range-based "for".
Diffstat (limited to 'src/db')
-rw-r--r--src/db/Count.cxx4
-rw-r--r--src/db/DatabasePrint.cxx4
-rw-r--r--src/db/Helpers.cxx4
3 files changed, 3 insertions, 9 deletions
diff --git a/src/db/Count.cxx b/src/db/Count.cxx
index ec3eacd1f..4fd53a73b 100644
--- a/src/db/Count.cxx
+++ b/src/db/Count.cxx
@@ -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()));
diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx
index f6663311e..498aedf97 100644
--- a/src/db/DatabasePrint.cxx
+++ b/src/db/DatabasePrint.cxx
@@ -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;
}
diff --git a/src/db/Helpers.cxx b/src/db/Helpers.cxx
index b849e73e8..089b2b17d 100644
--- a/src/db/Helpers.cxx
+++ b/src/db/Helpers.cxx
@@ -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)