summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-03-09 16:09:53 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-11 20:15:48 +0100
commit91fbe3fe7812af236aa2ea3f76926de5760a7b91 (patch)
tree2742ad9a5796418e42ee1aba9dd795f83fbd01a9 /src/network
parent5295043908edd22a1e0a653deabc41f5c2970647 (diff)
HTTP2: port to QByteArrayView where it's trivial
Nothing serious, just was curious and played around a bit, so might as well merge it. There's much more here that could be done, but I lack the time to do it. Change-Id: Idd4ea09a7a413ed5911ffe16841f3d5c944ec1a5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/http2/bitstreams.cpp2
-rw-r--r--src/network/access/http2/bitstreams_p.h2
-rw-r--r--src/network/access/http2/hpacktable.cpp2
-rw-r--r--src/network/access/http2/hpacktable_p.h2
-rw-r--r--src/network/access/http2/huffman.cpp4
-rw-r--r--src/network/access/http2/huffman_p.h4
6 files changed, 8 insertions, 8 deletions
diff --git a/src/network/access/http2/bitstreams.cpp b/src/network/access/http2/bitstreams.cpp
index d22c7cd4ec..1c42b4e478 100644
--- a/src/network/access/http2/bitstreams.cpp
+++ b/src/network/access/http2/bitstreams.cpp
@@ -99,7 +99,7 @@ void BitOStream::write(quint32 src)
}
}
-void BitOStream::write(const QByteArray &src, bool compressed)
+void BitOStream::write(QByteArrayView src, bool compressed)
{
quint32 byteLen = src.size();
if (compressed && byteLen) {
diff --git a/src/network/access/http2/bitstreams_p.h b/src/network/access/http2/bitstreams_p.h
index fd1ed9cc30..60ff916c92 100644
--- a/src/network/access/http2/bitstreams_p.h
+++ b/src/network/access/http2/bitstreams_p.h
@@ -79,7 +79,7 @@ public:
// * 32-bit integers
// * strings
void write(quint32 src);
- void write(const QByteArray &src, bool compressed);
+ void write(QByteArrayView src, bool compressed);
quint64 bitLength() const;
quint64 byteLength() const;
diff --git a/src/network/access/http2/hpacktable.cpp b/src/network/access/http2/hpacktable.cpp
index d963cf261b..ec484c7ede 100644
--- a/src/network/access/http2/hpacktable.cpp
+++ b/src/network/access/http2/hpacktable.cpp
@@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE
namespace HPack
{
-HeaderSize entry_size(const QByteArray &name, const QByteArray &value)
+HeaderSize entry_size(QByteArrayView name, QByteArrayView value)
{
// 32 comes from HPACK:
// "4.1 Calculating Table Size
diff --git a/src/network/access/http2/hpacktable_p.h b/src/network/access/http2/hpacktable_p.h
index c9b353a863..196b75f72a 100644
--- a/src/network/access/http2/hpacktable_p.h
+++ b/src/network/access/http2/hpacktable_p.h
@@ -88,7 +88,7 @@ struct Q_AUTOTEST_EXPORT HeaderField
using HeaderSize = QPair<bool, quint32>;
-HeaderSize entry_size(const QByteArray &name, const QByteArray &value);
+HeaderSize entry_size(QByteArrayView name, QByteArrayView value);
inline HeaderSize entry_size(const HeaderField &entry)
{
diff --git a/src/network/access/http2/huffman.cpp b/src/network/access/http2/huffman.cpp
index 0efea24d2a..8f3e53b13c 100644
--- a/src/network/access/http2/huffman.cpp
+++ b/src/network/access/http2/huffman.cpp
@@ -381,7 +381,7 @@ void write_huffman_code(BitOStream &outputStream, const CodeEntry &code)
// That's from HPACK's specs - we deal with octets.
static_assert(std::numeric_limits<uchar>::digits == 8, "octets expected");
-quint64 huffman_encoded_bit_length(const QByteArray &inputData)
+quint64 huffman_encoded_bit_length(QByteArrayView inputData)
{
quint64 bitLength = 0;
for (int i = 0, e = inputData.size(); i < e; ++i)
@@ -390,7 +390,7 @@ quint64 huffman_encoded_bit_length(const QByteArray &inputData)
return bitLength;
}
-void huffman_encode_string(const QByteArray &inputData, BitOStream &outputStream)
+void huffman_encode_string(QByteArrayView inputData, BitOStream &outputStream)
{
for (int i = 0, e = inputData.size(); i < e; ++i) {
const auto value = uchar(inputData[i]);
diff --git a/src/network/access/http2/huffman_p.h b/src/network/access/http2/huffman_p.h
index 8c1ca7da6b..e52313f9e7 100644
--- a/src/network/access/http2/huffman_p.h
+++ b/src/network/access/http2/huffman_p.h
@@ -69,8 +69,8 @@ struct CodeEntry
class BitOStream;
-quint64 huffman_encoded_bit_length(const QByteArray &inputData);
-void huffman_encode_string(const QByteArray &inputData, BitOStream &outputStream);
+quint64 huffman_encoded_bit_length(QByteArrayView inputData);
+void huffman_encode_string(QByteArrayView inputData, BitOStream &outputStream);
// PrefixTable:
// Huffman codes with a small bit length