From fe157665cd89ea3bc6f10fc9485a01919b02793d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 18 Dec 2024 13:56:33 +0800 Subject: [PATCH] Avoid redundant copy --- src/base/http/requestparser.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index e55b1d0d6e7..bd93fa6cc33 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -164,7 +164,7 @@ bool RequestParser::parseStartLines(const QStringView data) if (line.at(0).isSpace() && !requestLines.isEmpty()) { // continuation of previous line - requestLines.last() += line.toString(); + requestLines.last() += line; } else { @@ -225,9 +225,7 @@ bool RequestParser::parseRequestLine(const QString &line) const QByteArrayView valueComponent = param.mid(eqCharPos + 1); const QString paramName = QString::fromUtf8( QByteArray::fromPercentEncoding(asQByteArray(nameComponent)).replace('+', ' ')); - const QByteArray paramValue = valueComponent.isNull() - ? QByteArray("") - : QByteArray::fromPercentEncoding(asQByteArray(valueComponent)).replace('+', ' '); + const QByteArray paramValue = QByteArray::fromPercentEncoding(asQByteArray(valueComponent)).replace('+', ' '); m_request.query[paramName] = paramValue; } @@ -337,7 +335,7 @@ bool RequestParser::parseFormData(const QByteArrayView data) } else { - if (!parseHeaderLine(line.toString(), headersMap)) + if (!parseHeaderLine(line, headersMap)) return false; } } @@ -348,7 +346,8 @@ bool RequestParser::parseFormData(const QByteArrayView data) if (headersMap.contains(filename)) { - m_request.files.append({headersMap[filename], headersMap[HEADER_CONTENT_TYPE], payload.toByteArray()}); + m_request.files.append({.filename = headersMap[filename], .type = headersMap[HEADER_CONTENT_TYPE] + , .data = payload.toByteArray()}); } else if (headersMap.contains(name)) {