diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-18 17:43:12 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-10-06 06:31:18 +0200 |
commit | d6aa7c338d73bc069eb8e25c500dfb19de0d5c8b (patch) | |
tree | 2bc801cf4233a0a9b5cdb528347648703a0f9698 | |
parent | 978039651e23629b58f35b0c011a8ea76a5a774e (diff) |
Prefer QStringView's operator[] over its at()
Change-Id: Ibe2c450aa69ac7ea6db1e6a2174e17f31b4be9a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 4a5437c692..3ddad29080 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -161,8 +161,8 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) QDate date; const auto isShortName = [](QStringView name) { - return (name.length() == 3 && name.at(0).isUpper() - && name.at(1).isLower() && name.at(2).isLower()); + return (name.length() == 3 && name[0].isUpper() + && name[1].isLower() && name[2].isLower()); }; /* Reject entirely (return) if the string is malformed; however, if the date @@ -174,7 +174,7 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) bool rfcX22 = true; if (words.at(0).endsWith(u',')) { dayName = words.takeFirst().chopped(1); - } else if (!words.at(0).at(0).isDigit()) { + } else if (!words.at(0)[0].isDigit()) { dayName = words.takeFirst(); rfcX22 = false; } // else: dayName is not specified (so we can only be RFC *22) @@ -228,7 +228,7 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) QTime time; if (words.size() && words.at(0).contains(colon)) { const QStringView when = words.takeFirst(); - if (when.at(2) != colon || (when.size() == 8 ? when.at(5) != colon : when.size() > 5)) + if (when[2] != colon || (when.size() == 8 ? when[5] != colon : when.size() > 5)) return result; const int hour = when.left(2).toInt(&ok); if (!ok) @@ -249,9 +249,9 @@ static ParsedRfcDateTime rfcDateImpl(QStringView s) if (words.size() || !(zone.size() == 3 || zone.size() == 5)) return result; bool negate = false; - if (zone.at(0) == u'-') + if (zone[0] == u'-') negate = true; - else if (zone.at(0) != u'+') + else if (zone[0] != u'+') return result; const int hour = zone.mid(1, 2).toInt(&ok); if (!ok) @@ -296,7 +296,7 @@ static int fromOffsetString(QStringView offsetString, bool *valid) noexcept int sign; // First char must be + or - - const QChar signChar = offsetString.at(0); + const QChar signChar = offsetString[0]; if (signChar == u'+') sign = 1; else if (signChar == u'-') |