Avoid redundant string length function calls

Also switch to `std::string_view` as it is more generic and can handle more types (including
view types).

PR #21861.
This commit is contained in:
Chocobo1
2024-11-19 02:53:16 +08:00
committed by GitHub
parent 530631322d
commit 6ddde3f4b6
9 changed files with 112 additions and 108 deletions

View File

@@ -50,7 +50,7 @@ using QStringPair = std::pair<QString, QString>;
namespace
{
const QByteArray EOH = QByteArray(CRLF).repeated(2);
const QByteArray EOH = CRLF.repeated(2);
const QByteArrayView viewWithoutEndingWith(const QByteArrayView in, const QByteArrayView str)
{

View File

@@ -29,6 +29,7 @@
#pragma once
#include <QByteArray>
#include <QHostAddress>
#include <QList>
#include <QString>
@@ -76,7 +77,7 @@ namespace Http
inline const QString CONTENT_TYPE_FORM_DATA = u"multipart/form-data"_s;
// portability: "\r\n" doesn't guarantee mapping to the correct symbol
inline const char CRLF[] = {0x0D, 0x0A, '\0'};
inline const QByteArray CRLF = QByteArrayLiteral("\x0D\x0A");
struct Environment
{