diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-08-12 13:59:40 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-08-16 19:26:29 +0200 |
commit | 0756b6a719436a1c7b139ea93f5164f1f0b7f872 (patch) | |
tree | a7352bd80b270223dd948c1a79bfa56e34636b5c /src | |
parent | 01fdc174932d16099dac667eb5688643f18bc9fb (diff) |
QDateTime: port away from takeFirst() use
Use the std-compatible API subset instead.
This is in preparation of using QVarLengthArray instead of QList here,
which (thankfully, because it's inefficient for arbitray T) doesn't
have pop_front().
As a drive-by, port at(0) to front() and introduce a temporary
variable. The front() call will briefly emit a detach attempt (but the
container isn't shared, so it won't actually detach), but only until
the next patch ports to QVLA.
Change-Id: I38ee123aa6730aee5ba1e14ec46fc71c5d74986e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 65c705907a..9ddd207662 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -172,10 +172,13 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) do { // "loop" so that we can use break on merely invalid, but "right shape" date. QStringView dayName; bool rfcX22 = true; - if (words.at(0).endsWith(u',')) { - dayName = words.takeFirst().chopped(1); - } else if (!words.at(0)[0].isDigit()) { - dayName = words.takeFirst(); + const QStringView maybeDayName = words.front(); + if (maybeDayName.endsWith(u',')) { + dayName = maybeDayName.chopped(1); + words.erase(words.begin()); + } else if (!maybeDayName.front().isDigit()) { + dayName = maybeDayName; + words.erase(words.begin()); rfcX22 = false; } // else: dayName is not specified (so we can only be RFC *22) if (words.size() < 3 || words.size() > 5) @@ -227,7 +230,8 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) // Time: [hh:mm[:ss]] QTime time; if (words.size() && words.at(0).contains(colon)) { - const QStringView when = words.takeFirst(); + const QStringView when = words.front(); + words.erase(words.begin()); if (when.size() < 5 || when[2] != colon || (when.size() == 8 ? when[5] != colon : when.size() > 5)) { return result; @@ -247,7 +251,8 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) // Offset: [±hh[mm]] int offset = 0; if (words.size()) { - const QStringView zone = words.takeFirst(); + const QStringView zone = words.front(); + words.erase(words.begin()); if (words.size() || !(zone.size() == 3 || zone.size() == 5)) return result; bool negate = false; |