From a0032d285f9148a9ae7f46e2d9c0e24a6fa84d0d Mon Sep 17 00:00:00 2001 From: Kurt Pattyn Date: Sat, 12 Oct 2013 21:00:17 +0200 Subject: [PATCH] Call other mask function instead of implementing it twice Change-Id: Ib196422ed7de2da420010e89347c98a02affef9a Reviewed-by: Steven Ceuppens --- src/websockets/qwebsocketprotocol.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/websockets/qwebsocketprotocol.cpp b/src/websockets/qwebsocketprotocol.cpp index e1f3afb..9acc8ed 100644 --- a/src/websockets/qwebsocketprotocol.cpp +++ b/src/websockets/qwebsocketprotocol.cpp @@ -134,24 +134,7 @@ Version versionFromString(const QString &versionString) */ void mask(QByteArray *payload, quint32 maskingKey) { - quint32 *payloadData = reinterpret_cast(payload->data()); - const quint32 numIterations = static_cast(payload->size()) / sizeof(quint32); - const quint32 remainder = static_cast(payload->size()) % sizeof(quint32); - quint32 i; - for (i = 0; i < numIterations; ++i) - { - *(payloadData + i) ^= maskingKey; - } - if (remainder) - { - const quint32 offset = i * static_cast(sizeof(quint32)); - char *payloadBytes = payload->data(); - const uchar *mask = reinterpret_cast(&maskingKey); - for (quint32 i = 0; i < remainder; ++i) - { - *(payloadBytes + offset + i) ^= static_cast(mask[(i + offset) % 4]); - } - } + mask(payload->data(), payload->size(), maskingKey); } /*! -- 2.7.4