Browse Source

Avoid needless string-bytes conversion

This saves a few microseconds.
adaptive-webui-19844
Chocobo1 3 years ago
parent
commit
ad9d0608d4
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 16
      src/base/http/responsegenerator.cpp

16
src/base/http/responsegenerator.cpp

@ -45,16 +45,20 @@ QByteArray Http::toByteArray(Response response) @@ -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;

Loading…
Cancel
Save