mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-05 11:21:09 +03:00
Create IOBuf on the stack using folly::IOBuf::wrapBufferAsValue for body
Summary: This is similar to the previous commit. We use a stack-based IOBuf instead of allocating one on the heap. This saves CPU because allocations/deallocations on the stack are a lot cheaper. Reviewed By: hanidamlaj Differential Revision: D53101722 fbshipit-source-id: dd59a7eca6498db19472a62f954db3e2f2f27a42
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5a131b6f04
commit
303c405e10
@@ -149,8 +149,8 @@ uint64_t getEncodedSize(const RegularQuicPacketBuilder::Packet& packet) {
|
||||
if (!packet.header.empty()) {
|
||||
encodedSize += packet.header.computeChainDataLength();
|
||||
}
|
||||
if (packet.body) {
|
||||
encodedSize += packet.body->computeChainDataLength();
|
||||
if (!packet.body.empty()) {
|
||||
encodedSize += packet.body.computeChainDataLength();
|
||||
}
|
||||
return encodedSize;
|
||||
}
|
||||
@@ -158,8 +158,8 @@ uint64_t getEncodedSize(const RegularQuicPacketBuilder::Packet& packet) {
|
||||
uint64_t getEncodedBodySize(const RegularQuicPacketBuilder::Packet& packet) {
|
||||
// calculate size as the plaintext size
|
||||
uint32_t encodedBodySize = 0;
|
||||
if (packet.body) {
|
||||
encodedBodySize += packet.body->computeChainDataLength();
|
||||
if (!packet.body.empty()) {
|
||||
encodedBodySize += packet.body.computeChainDataLength();
|
||||
}
|
||||
return encodedBodySize;
|
||||
}
|
||||
@@ -1177,7 +1177,8 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
|
||||
auto packet = buildEmptyPacket(*conn, PacketNumberSpace::Handshake);
|
||||
auto packetEncodedSize =
|
||||
!packet.header.empty() ? packet.header.computeChainDataLength() : 0;
|
||||
packetEncodedSize += packet.body ? packet.body->computeChainDataLength() : 0;
|
||||
packetEncodedSize +=
|
||||
!packet.body.empty() ? packet.body.computeChainDataLength() : 0;
|
||||
|
||||
packet.packet.frames.push_back(WriteCryptoFrame(0, 0));
|
||||
updateConnection(
|
||||
@@ -1194,8 +1195,9 @@ TEST_F(QuicTransportFunctionsTest, TestUpdateConnectionHandshakeCounter) {
|
||||
packetEncodedSize = !nonHandshake.header.empty()
|
||||
? nonHandshake.header.computeChainDataLength()
|
||||
: 0;
|
||||
packetEncodedSize +=
|
||||
nonHandshake.body ? nonHandshake.body->computeChainDataLength() : 0;
|
||||
packetEncodedSize += !nonHandshake.body.empty()
|
||||
? nonHandshake.body.computeChainDataLength()
|
||||
: 0;
|
||||
auto stream1 = conn->streamManager->createNextBidirectionalStream().value();
|
||||
writeDataToQuicStream(*stream1, nullptr, true);
|
||||
|
||||
|
Reference in New Issue
Block a user