Narrow the scope of iterators

Also make sure that it is visible at first glance that iterators are
not taken from temporaries.
This commit is contained in:
Urs Fleisch
2023-07-16 06:41:53 +02:00
parent c2c9e8989c
commit 77ab5e9689
17 changed files with 44 additions and 80 deletions

View File

@ -213,8 +213,7 @@ ByteVectorList Ogg::Page::packets() const
const List<int> packetSizes = d->header.packetSizes();
auto it = packetSizes.begin();
for(; it != packetSizes.end(); ++it)
for(auto it = packetSizes.begin(); it != packetSizes.end(); ++it)
l.append(d->file->readBlock(*it));
}
else
@ -243,8 +242,7 @@ ByteVector Ogg::Page::render() const
debug("Ogg::Page::render() -- this page is empty!");
}
else {
auto it = d->packets.cbegin();
for(; it != d->packets.cend(); ++it)
for(auto it = d->packets.cbegin(); it != d->packets.cend(); ++it)
data.append(*it);
}

View File

@ -234,8 +234,7 @@ PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties)
// now go through keys in \a properties and check that the values match those in the xiph comment
PropertyMap invalid;
auto it = properties.begin();
for(; it != properties.end(); ++it)
for(auto it = properties.begin(); it != properties.end(); ++it)
{
if(!checkKey(it->first))
invalid.insert(it->first, it->second);
@ -366,16 +365,14 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const
// std::pair<String, StringList> where the first String is the field name and
// the StringList is the values associated with that field.
auto it = d->fieldListMap.cbegin();
for(; it != d->fieldListMap.cend(); ++it) {
for(auto it = d->fieldListMap.cbegin(); it != d->fieldListMap.cend(); ++it) {
// And now iterate over the values of the current list.
String fieldName = (*it).first;
const StringList values = (*it).second;
auto valuesIt = values.begin();
for(; valuesIt != values.end(); ++valuesIt) {
for(auto valuesIt = values.begin(); valuesIt != values.end(); ++valuesIt) {
ByteVector fieldData = fieldName.data(String::UTF8);
fieldData.append('=');
fieldData.append((*valuesIt).data(String::UTF8));