From 41a7203c28d2cc7550f1bb05f767950d388326cd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Jul 2014 17:22:39 +0200 Subject: Tag: add class const_iterator and methods begin(), end() Enables using range-based "for". --- src/SongFilter.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/SongFilter.cxx') diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index 0640ae19e..7a8e6fd12 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -92,10 +92,10 @@ SongFilter::Item::Match(const Tag &_tag) const bool visited_types[TAG_NUM_OF_ITEM_TYPES]; std::fill_n(visited_types, size_t(TAG_NUM_OF_ITEM_TYPES), false); - for (unsigned i = 0; i < _tag.num_items; i++) { - visited_types[_tag.items[i]->type] = true; + for (const auto &i : _tag) { + visited_types[i.type] = true; - if (Match(*_tag.items[i])) + if (Match(i)) return true; } @@ -112,12 +112,10 @@ SongFilter::Item::Match(const Tag &_tag) const if (tag == TAG_ALBUM_ARTIST && visited_types[TAG_ARTIST]) { /* if we're looking for "album artist", but only "artist" exists, use that */ - for (unsigned i = 0; i < _tag.num_items; i++) { - const TagItem &item = *_tag.items[i]; + for (const auto &item : _tag) if (item.type == TAG_ARTIST && StringMatch(item.value)) return true; - } } } -- cgit v1.2.3