Pass HPack::BitPattern by value
It is a small and trivially copyable type. Found by an Axivion scan. As a drive-by, forward-declare struct BitPattern at namespace scope instead of in the argument of a function declaration. Task-number: QTBUG-125026 Pick-to: 6.7 6.5 Change-Id: Ic3f58cb71a0fd0ad5b0555767af879e813612e72 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 9a41ea0934a745aa4e33280a2cf7a45372cb4073) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
68608585a5
commit
504968117a
@ -35,7 +35,7 @@ struct BitPattern
|
||||
uchar bitLength;
|
||||
};
|
||||
|
||||
bool operator == (const BitPattern &lhs, const BitPattern &rhs)
|
||||
bool operator==(BitPattern lhs, BitPattern rhs)
|
||||
{
|
||||
return lhs.bitLength == rhs.bitLength && lhs.value == rhs.value;
|
||||
}
|
||||
@ -60,19 +60,19 @@ const BitPattern LiteralNoIndexing = {0, 4};
|
||||
const BitPattern LiteralNeverIndexing = {1, 4};
|
||||
const BitPattern SizeUpdate = {1, 3};
|
||||
|
||||
bool is_literal_field(const BitPattern &pattern)
|
||||
bool is_literal_field(BitPattern pattern)
|
||||
{
|
||||
return pattern == LiteralIncrementalIndexing
|
||||
|| pattern == LiteralNoIndexing
|
||||
|| pattern == LiteralNeverIndexing;
|
||||
}
|
||||
|
||||
void write_bit_pattern(const BitPattern &pattern, BitOStream &outputStream)
|
||||
void write_bit_pattern(BitPattern pattern, BitOStream &outputStream)
|
||||
{
|
||||
outputStream.writeBits(pattern.value, pattern.bitLength);
|
||||
}
|
||||
|
||||
bool read_bit_pattern(const BitPattern &pattern, BitIStream &inputStream)
|
||||
bool read_bit_pattern(BitPattern pattern, BitIStream &inputStream)
|
||||
{
|
||||
uchar chunk = 0;
|
||||
|
||||
@ -319,7 +319,7 @@ bool Encoder::encodeIndexedField(BitOStream &outputStream, quint32 index) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Encoder::encodeLiteralField(BitOStream &outputStream, const BitPattern &fieldType,
|
||||
bool Encoder::encodeLiteralField(BitOStream &outputStream, BitPattern fieldType,
|
||||
const QByteArray &name, const QByteArray &value,
|
||||
bool withCompression)
|
||||
{
|
||||
@ -347,7 +347,7 @@ bool Encoder::encodeLiteralField(BitOStream &outputStream, const BitPattern &fie
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Encoder::encodeLiteralField(BitOStream &outputStream, const BitPattern &fieldType,
|
||||
bool Encoder::encodeLiteralField(BitOStream &outputStream, BitPattern fieldType,
|
||||
quint32 nameIndex, const QByteArray &value,
|
||||
bool withCompression)
|
||||
{
|
||||
@ -451,7 +451,7 @@ bool Decoder::decodeSizeUpdate(BitIStream &inputStream)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Decoder::decodeLiteralField(const BitPattern &fieldType, BitIStream &inputStream)
|
||||
bool Decoder::decodeLiteralField(BitPattern fieldType, BitIStream &inputStream)
|
||||
{
|
||||
// https://http2.github.io/http2-spec/compression.html
|
||||
// 6.2.1, 6.2.2, 6.2.3
|
||||
@ -481,7 +481,7 @@ bool Decoder::decodeLiteralField(const BitPattern &fieldType, BitIStream &inputS
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Decoder::processDecodedField(const BitPattern &fieldType,
|
||||
bool Decoder::processDecodedField(BitPattern fieldType,
|
||||
const QByteArray &name,
|
||||
const QByteArray &value)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ namespace HPack
|
||||
|
||||
using HttpHeader = std::vector<HeaderField>;
|
||||
HeaderSize header_size(const HttpHeader &header);
|
||||
|
||||
struct BitPattern;
|
||||
class Q_AUTOTEST_EXPORT Encoder
|
||||
{
|
||||
public:
|
||||
@ -66,13 +66,13 @@ private:
|
||||
|
||||
|
||||
bool encodeLiteralField(BitOStream &outputStream,
|
||||
const struct BitPattern &fieldType,
|
||||
BitPattern fieldType,
|
||||
quint32 nameIndex,
|
||||
const QByteArray &value,
|
||||
bool withCompression);
|
||||
|
||||
bool encodeLiteralField(BitOStream &outputStream,
|
||||
const BitPattern &fieldType,
|
||||
BitPattern fieldType,
|
||||
const QByteArray &name,
|
||||
const QByteArray &value,
|
||||
bool withCompression);
|
||||
@ -101,10 +101,10 @@ private:
|
||||
|
||||
bool decodeIndexedField(BitIStream &inputStream);
|
||||
bool decodeSizeUpdate(BitIStream &inputStream);
|
||||
bool decodeLiteralField(const BitPattern &fieldType,
|
||||
bool decodeLiteralField(BitPattern fieldType,
|
||||
BitIStream &inputStream);
|
||||
|
||||
bool processDecodedField(const BitPattern &fieldType,
|
||||
bool processDecodedField(BitPattern fieldType,
|
||||
const QByteArray &name,
|
||||
const QByteArray &value);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user