diff options
author | Anton Kudryavtsev <anton.kudryavtsev@vk.team> | 2023-08-23 14:58:40 +0300 |
---|---|---|
committer | Anton Kudryavtsev <anton.kudryavtsev@vk.team> | 2023-08-25 14:33:51 +0300 |
commit | 002c2723c955f66fbbc2e4a66f195c3148cb9e47 (patch) | |
tree | 9ed39c383ed504d56c372236f0dd42f549a444f6 | |
parent | ea25b3962b90154f8c6eba0951ee1c58fe873139 (diff) |
qnetworkcookie: reduce allocations
by using QBAV::toInt instead of creating temp QBA + atoi
Change-Id: I90dd78e3fd989930071e3bd99c914087409aa948
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | src/network/access/qnetworkcookie.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 7ecc9c0b6c..5f27272d37 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -576,7 +576,7 @@ static inline bool isValueSeparator(char c) static inline bool isWhitespace(char c) { return c == ' ' || c == '\t'; } -static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, int size) +static bool checkStaticArray(int &val, QByteArrayView dateString, int at, const char *array, int size) { if (dateString[at] < 'a' || dateString[at] > 'z') return false; @@ -623,7 +623,7 @@ static bool checkStaticArray(int &val, const QByteArray &dateString, int at, con Or in their own words: "} // else what the hell is this." */ -static QDateTime parseDateString(const QByteArray &dateString) +static QDateTime parseDateString(QByteArrayView dateString) { QTime time; // placeholders for values when we are not sure it is a year, month or day @@ -686,13 +686,13 @@ static QDateTime parseDateString(const QByteArray &dateString) int hours = 0; switch (end - 1) { case 4: - minutes = atoi(dateString.mid(at + 3, 2).constData()); + minutes = dateString.mid(at + 3, 2).toInt(); Q_FALLTHROUGH(); case 2: - hours = atoi(dateString.mid(at + 1, 2).constData()); + hours = dateString.mid(at + 1, 2).toInt(); break; case 1: - hours = atoi(dateString.mid(at + 1, 1).constData()); + hours = dateString.mid(at + 1, 1).toInt(); break; default: at += end; @@ -743,7 +743,7 @@ static QDateTime parseDateString(const QByteArray &dateString) if (isNumber(dateString[at + 1]) && isNumber(dateString[at + 2]) && isNumber(dateString[at + 3])) { - year = atoi(dateString.mid(at, 4).constData()); + year = dateString.mid(at, 4).toInt(); at += 4; #ifdef PARSEDATESTRINGDEBUG qDebug() << "Year:" << year; @@ -759,7 +759,7 @@ static QDateTime parseDateString(const QByteArray &dateString) if (dateString.size() > at + 1 && isNumber(dateString[at + 1])) ++length; - int x = atoi(dateString.mid(at, length).constData()); + int x = dateString.mid(at, length).toInt(); if (year == -1 && (x > 31 || x == 0)) { year = x; } else { |