diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-18 16:10:12 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-18 14:24:31 +0000 |
commit | 195977f6e9e21e23a9ae3a13c9bbcea38eb5387b (patch) | |
tree | b7b7f885ce562c07ece82be2aff93f7dcc0650f2 /src/qml/compiler/qqmlirbuilder.cpp | |
parent | 9a59596ac02999ee068023d1d8cc779539eee491 (diff) |
QQmlIRBuilder: Turn Iterator into a iterator
The iterator class was missing the required typedefs which are expected
of iterators to support standard algorithms.
Also demonstrate that we can now use standard algorithms on the
containers by using find_if.
Change-Id: Ia03dee4cb89731f407393c340606c3d94f3edb9d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlirbuilder.cpp')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 940d61ba97..9623d2ed58 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -250,9 +250,11 @@ QString Object::appendAlias(Alias *alias, const QString &aliasName, bool isDefau if (!target) target = this; - for (Alias *p = target->aliases->first; p; p = p->next) - if (p->nameIndex == alias->nameIndex) - return tr("Duplicate alias name"); + auto aliasWithSameName = std::find_if(target->aliases->begin(), target->aliases->end(), [&alias](const Alias &targetAlias){ + return targetAlias.nameIndex == alias->nameIndex; + }); + if (aliasWithSameName != target->aliases->end()) + return tr("Duplicate alias name"); if (aliasName.constData()->isUpper()) return tr("Alias names cannot begin with an upper case letter"); |