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>
bb10
Marc Mutz 2022-03-09 16:09:53 +01:00
parent 5295043908
commit 91fbe3fe78
6 changed files with 8 additions and 8 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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

View File

@ -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)
{

View File

@ -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]);

View File

@ -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