Restore const iterators replaced in #1107 (#1128)

Also make sure that the lines calling std algorithms are not
excessively long.
This commit is contained in:
Urs Fleisch 2023-09-06 20:59:01 +02:00 committed by GitHub
parent 524b588a1e
commit 47c4e0859c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 11 deletions

View File

@ -59,8 +59,10 @@ namespace
static constexpr std::array invalidKeys { "ID3", "TAG", "OGGS", "MP+" };
// only allow printable ASCII including space (32..126)
return std::none_of(key.begin(), key.end(), [](unsigned char c) { return c < 32 || c > 126; })
&& std::none_of(invalidKeys.begin(), invalidKeys.end(), [upperKey = String(key).upper()](auto k) { return upperKey == k; });
return std::none_of(key.begin(), key.end(),
[](unsigned char c) { return c < 32 || c > 126; })
&& std::none_of(invalidKeys.begin(), invalidKeys.end(),
[upperKey = String(key).upper()](auto k) { return upperKey == k; });
}
} // namespace

View File

@ -103,7 +103,8 @@ MP4::Atom::Atom(File *file)
};
// meta is not a full atom (i.e. not followed by version, flags). It
// is followed by the size and type of the first child atom.
auto metaIsFullAtom = std::none_of(metaChildrenNames.begin(), metaChildrenNames.end(), [nextSize = file->readBlock(8).mid(4, 4)](const auto &child) { return nextSize == child; });
auto metaIsFullAtom = std::none_of(metaChildrenNames.begin(), metaChildrenNames.end(),
[nextSize = file->readBlock(8).mid(4, 4)](const auto &child) { return nextSize == child; });
// Only skip next four bytes, which contain version and flags, if meta
// is a full atom.
file->seek(posAfterMeta + (metaIsFullAtom ? 4 : 0));

View File

@ -36,7 +36,8 @@ namespace
{
bool checkValid(const MP4::AtomList &list)
{
return std::none_of(list.begin(), list.end(), [](const auto &a) { return a->length == 0 || !checkValid(a->children); });
return std::none_of(list.begin(), list.end(),
[](const auto &a) { return a->length == 0 || !checkValid(a->children); });
}
} // namespace

View File

@ -25,6 +25,8 @@
#include "tableofcontentsframe.h"
#include <utility>
#include "tbytevectorlist.h"
#include "tpropertymap.h"
#include "tdebug.h"
@ -321,11 +323,11 @@ ByteVector TableOfContentsFrame::renderFields() const
flags += 1;
data.append(flags);
data.append(static_cast<char>(entryCount()));
for(const auto &element : d->childElements) {
for(const auto &element : std::as_const(d->childElements)) {
data.append(element);
data.append('\0');
}
for(const auto &frame : d->embeddedFrameList) {
for(const auto &frame : std::as_const(d->embeddedFrameList)) {
frame->header()->setVersion(header()->version());
data.append(frame->render());
}

View File

@ -294,7 +294,8 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const
}
const StringList l = fieldList();
for(auto it = l.begin(); it != l.end(); ++it) {
auto found = std::find_if(involvedPeople.begin(), involvedPeople.end(), [=](const auto &person) { return *it == person.first; });
auto found = std::find_if(involvedPeople.begin(), involvedPeople.end(),
[=](const auto &person) { return *it == person.first; });
if(found != involvedPeople.end()) {
map.insert(found->second, (++it)->split(","));
}

View File

@ -69,7 +69,8 @@ namespace
if(frameID.size() != 4)
return false;
return std::none_of(frameID.begin(), frameID.end(), [](auto c) { return (c < 'A' || c > 'Z') && (c < '0' || c > '9'); });
return std::none_of(frameID.begin(), frameID.end(),
[](auto c) { return (c < 'A' || c > 'Z') && (c < '0' || c > '9'); });
}
} // namespace

View File

@ -143,7 +143,8 @@ std::pair<Frame::Header *, bool> FrameFactory::prepareFrameHeader(
}
#endif
if(std::any_of(frameID.begin(), frameID.end(), [](auto c) { return (c < 'A' || c > 'Z') && (c < '0' || c > '9'); })) {
if(std::any_of(frameID.cbegin(), frameID.cend(),
[](auto c) { return (c < 'A' || c > 'Z') && (c < '0' || c > '9'); })) {
delete header;
return { nullptr, false };
}

View File

@ -191,7 +191,8 @@ void Ogg::XiphComment::setTrack(unsigned int i)
bool Ogg::XiphComment::isEmpty() const
{
return std::all_of(d->fieldListMap.begin(), d->fieldListMap.end(), [](const auto &field) { return field.second.isEmpty(); });
return std::all_of(d->fieldListMap.cbegin(), d->fieldListMap.cend(),
[](const auto &field) { return field.second.isEmpty(); });
}
unsigned int Ogg::XiphComment::fieldCount() const

View File

@ -97,7 +97,8 @@ bool PropertyMap::contains(const String &key) const
bool PropertyMap::contains(const PropertyMap &other) const
{
return std::all_of(other.begin(), other.end(), [this](const auto &o) { return contains(o.first) && (*this)[o.first] == o.second; });
return std::all_of(other.begin(), other.end(),
[this](const auto &o) { return contains(o.first) && (*this)[o.first] == o.second; });
}
PropertyMap &PropertyMap::erase(const String &key)