summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-01-18 01:32:30 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-18 14:45:46 +0100
commit3359932202f79b0fa80ae8d3a6ec73f35b34c738 (patch)
treeb452b15c63e073db4b3e19b6ee19db159af89d6d
parentabf5f99d1808bbf18b8ebbe2b9468d409fe77158 (diff)
downloadqtwebsockets-3359932202f79b0fa80ae8d3a6ec73f35b34c738.tar.gz
Use QString() instead of QStringLiteral("")
And do the same for QByteArray. Instantiating the default constructor uses QArrayData::sharedNull() for the d-pointer which is the cheapest constructor in memory and instructions. Change-Id: I1ceaafbc0c0cb1ccc5690edba89ea1100f30b3cd Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
-rw-r--r--src/websockets/qwebsocket_p.cpp16
-rw-r--r--src/websockets/qwebsockethandshakerequest.cpp10
-rw-r--r--tests/auto/websocketcorsauthenticator/tst_websocketcorsauthenticator.cpp2
-rw-r--r--tests/auto/websocketframe/tst_websocketframe.cpp8
-rw-r--r--tests/auto/websocketprotocol/tst_websocketprotocol.cpp2
5 files changed, 19 insertions, 19 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 8c86aba..6a027da 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -887,16 +887,16 @@ void QWebSocketPrivate::processHandshake(QTcpSocket *pSocket)
}
const QString acceptKey = headers.value(QStringLiteral("Sec-WebSocket-Accept"),
- QStringLiteral(""));
- const QString upgrade = headers.value(QStringLiteral("Upgrade"), QStringLiteral(""));
- const QString connection = headers.value(QStringLiteral("Connection"), QStringLiteral(""));
+ QString());
+ const QString upgrade = headers.value(QStringLiteral("Upgrade"), QString());
+ const QString connection = headers.value(QStringLiteral("Connection"), QString());
// unused for the moment
// const QString extensions = headers.value(QStringLiteral("Sec-WebSocket-Extensions"),
-// QStringLiteral(""));
+// QString());
// const QString protocol = headers.value(QStringLiteral("Sec-WebSocket-Protocol"),
-// QStringLiteral(""));
+// QString());
const QString version = headers.value(QStringLiteral("Sec-WebSocket-Version"),
- QStringLiteral(""));
+ QString());
if (Q_LIKELY(httpStatusCode == 101)) {
//HTTP/x.y 101 Switching Protocols
@@ -975,8 +975,8 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS
% QStringLiteral(":")
% QString::number(m_requestUrl.port(80)),
origin(),
- QStringLiteral(""),
- QStringLiteral(""),
+ QString(),
+ QString(),
m_key);
m_pSocket->write(handshake.toLatin1());
}
diff --git a/src/websockets/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp
index fbc25a7..c47dfd0 100644
--- a/src/websockets/qwebsockethandshakerequest.cpp
+++ b/src/websockets/qwebsockethandshakerequest.cpp
@@ -229,7 +229,7 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream)
headerLine = textStream.readLine();
}
- const QString host = m_headers.value(QStringLiteral("Host"), QStringLiteral(""));
+ const QString host = m_headers.value(QStringLiteral("Host"), QString());
m_requestUrl = QUrl::fromEncoded(resourceName.toLatin1());
if (m_requestUrl.isRelative())
m_requestUrl.setHost(host);
@@ -255,11 +255,11 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream)
}
//sort in descending order
std::sort(m_versions.begin(), m_versions.end(), std::greater<QWebSocketProtocol::Version>());
- m_key = m_headers.value(QStringLiteral("Sec-WebSocket-Key"), QStringLiteral(""));
+ m_key = m_headers.value(QStringLiteral("Sec-WebSocket-Key"), QString());
//must contain "Upgrade", case-insensitive
- const QString upgrade = m_headers.value(QStringLiteral("Upgrade"), QStringLiteral(""));
+ const QString upgrade = m_headers.value(QStringLiteral("Upgrade"), QString());
//must be equal to "websocket", case-insensitive
- const QString connection = m_headers.value(QStringLiteral("Connection"), QStringLiteral(""));
+ const QString connection = m_headers.value(QStringLiteral("Connection"), QString());
const QStringList connectionLine = connection.split(QStringLiteral(","),
QString::SkipEmptyParts);
QStringList connectionValues;
@@ -267,7 +267,7 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream)
connectionValues << (*c).trimmed();
//optional headers
- m_origin = m_headers.value(QStringLiteral("Sec-WebSocket-Origin"), QStringLiteral(""));
+ m_origin = m_headers.value(QStringLiteral("Sec-WebSocket-Origin"), QString());
const QStringList protocolLines = m_headers.values(QStringLiteral("Sec-WebSocket-Protocol"));
for (QStringList::const_iterator pl = protocolLines.begin(); pl != protocolLines.end(); ++pl) {
QStringList protocols = (*pl).split(QStringLiteral(","), QString::SkipEmptyParts);
diff --git a/tests/auto/websocketcorsauthenticator/tst_websocketcorsauthenticator.cpp b/tests/auto/websocketcorsauthenticator/tst_websocketcorsauthenticator.cpp
index 6d44241..7bb44b1 100644
--- a/tests/auto/websocketcorsauthenticator/tst_websocketcorsauthenticator.cpp
+++ b/tests/auto/websocketcorsauthenticator/tst_websocketcorsauthenticator.cpp
@@ -92,7 +92,7 @@ void tst_WebSocketCorsAuthenticator::cleanup()
void tst_WebSocketCorsAuthenticator::tst_initialization()
{
{
- QWebSocketCorsAuthenticator authenticator(QStringLiteral(""));
+ QWebSocketCorsAuthenticator authenticator((QString()));
QCOMPARE(authenticator.allowed(), true);
QCOMPARE(authenticator.origin(), QString());
diff --git a/tests/auto/websocketframe/tst_websocketframe.cpp b/tests/auto/websocketframe/tst_websocketframe.cpp
index e3f3e12..46a360a 100644
--- a/tests/auto/websocketframe/tst_websocketframe.cpp
+++ b/tests/auto/websocketframe/tst_websocketframe.cpp
@@ -274,12 +274,12 @@ void tst_WebSocketFrame::tst_goodFrames_data()
QTest::newRow("Non masked final text frame with no payload")
<< 0 << 0 << 0
<< 0U << QWebSocketProtocol::OC_TEXT
- << true << QByteArrayLiteral("")
+ << true << QByteArray()
<< false << true << false;
QTest::newRow("Non masked final binary frame with no payload")
<< 0 << 0 << 0
<< 0U << QWebSocketProtocol::OC_BINARY
- << true << QByteArrayLiteral("")
+ << true << QByteArray()
<< false << true << false;
QTest::newRow("Non masked final close frame with small payload")
@@ -290,7 +290,7 @@ void tst_WebSocketFrame::tst_goodFrames_data()
QTest::newRow("Non masked final close frame with no payload")
<< 0 << 0 << 0
<< 0U << QWebSocketProtocol::OC_CLOSE
- << true << QByteArrayLiteral("")
+ << true << QByteArray()
<< true << false << false;
QTest::newRow("Non masked final ping frame with small payload")
<< 0 << 0 << 0
@@ -300,7 +300,7 @@ void tst_WebSocketFrame::tst_goodFrames_data()
QTest::newRow("Non masked final pong frame with no payload")
<< 0 << 0 << 0
<< 0U << QWebSocketProtocol::OC_PONG
- << true << QByteArrayLiteral("")
+ << true << QByteArray()
<< true << false << false;
QTest::newRow("Non masked final continuation frame with small payload")
diff --git a/tests/auto/websocketprotocol/tst_websocketprotocol.cpp b/tests/auto/websocketprotocol/tst_websocketprotocol.cpp
index 433d53a..fa3177c 100644
--- a/tests/auto/websocketprotocol/tst_websocketprotocol.cpp
+++ b/tests/auto/websocketprotocol/tst_websocketprotocol.cpp
@@ -101,7 +101,7 @@ void tst_WebSocketProtocol::tst_validMasks_data()
QTest::addColumn<QString>("inputdata");
QTest::addColumn<QByteArray>("result");
- QTest::newRow("Empty payload") << 0x12345678u << QStringLiteral("") << QByteArrayLiteral("");
+ QTest::newRow("Empty payload") << 0x12345678u << QString() << QByteArray();
QTest::newRow("ASCII payload of 8 characters") << 0x12345678u << QStringLiteral("abcdefgh") << QByteArrayLiteral("\x73\x56\x35\x1C\x77\x52\x31\x10");
QTest::newRow("ASCII payload of 9 characters") << 0x12345678u << QStringLiteral("abcdefghi") << QByteArrayLiteral("\x73\x56\x35\x1C\x77\x52\x31\x10\x7B");
//MSVC doesn't like UTF-8 in source code; the following text is represented in the string below: ∫∂ƒ©øØ