diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-05-18 14:49:04 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-12-05 00:47:44 +0100 |
commit | 105a66e6543467863a39cd12271f125b45d74179 (patch) | |
tree | 3362c298e5e930b6a7791584fe065aa0f8bd8a57 /src/corelib/text/qstringlist.cpp | |
parent | f19266bd02a01d4b7b277ea769c4c17727b1e661 (diff) |
Use (new) erase()/erase_if() algorithms
Change-Id: I45c18fd45c20b226e44d16315e3ebb6c305d4ab0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstringlist.cpp')
-rw-r--r-- | src/corelib/text/qstringlist.cpp | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp index c395750376..440e26bc89 100644 --- a/src/corelib/text/qstringlist.cpp +++ b/src/corelib/text/qstringlist.cpp @@ -648,22 +648,9 @@ qsizetype QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QReg */ qsizetype QtPrivate::QStringList_removeDuplicates(QStringList *that) { - qsizetype n = that->size(); - qsizetype j = 0; - QDuplicateTracker<QString> seen; - seen.reserve(n); - for (qsizetype i = 0; i < n; ++i) { - const QString &s = that->at(i); - if (seen.hasSeen(s)) - continue; - if (j != i) - that->swapItemsAt(i, j); - ++j; - } - if (n != j) - that->erase(that->begin() + j, that->end()); - return n - j; + seen.reserve(that->size()); + return that->removeIf([&](const QString &s) { return seen.hasSeen(s); }); } QT_END_NAMESPACE |