From ad9d0608d4a1996fa443c4b6abc63a8afdf2040b Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 13 Dec 2021 01:56:20 +0800 Subject: [PATCH] Avoid needless string-bytes conversion This saves a few microseconds. --- src/base/http/responsegenerator.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/base/http/responsegenerator.cpp b/src/base/http/responsegenerator.cpp index cd0f959fb..ccbacd1d4 100644 --- a/src/base/http/responsegenerator.cpp +++ b/src/base/http/responsegenerator.cpp @@ -45,16 +45,20 @@ QByteArray Http::toByteArray(Response response) buf.reserve(1024 + response.content.length()); // Status Line - buf += QString("HTTP/%1 %2 %3") - .arg("1.1", // TODO: depends on request - QString::number(response.status.code), - response.status.text) - .toLatin1() + buf.append("HTTP/1.1 ") // TODO: depends on request + .append(QByteArray::number(response.status.code)) + .append(' ') + .append(response.status.text.toLatin1()) .append(CRLF); // Header Fields for (auto i = response.headers.constBegin(); i != response.headers.constEnd(); ++i) - buf += QString::fromLatin1("%1: %2").arg(i.key(), i.value()).toLatin1().append(CRLF); + { + buf.append(i.key().toLatin1()) + .append(": ") + .append(i.value().toLatin1()) + .append(CRLF); + } // the first empty line buf += CRLF;