mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-12-07 16:02:14 +03:00
Custom variant type for packetheader
Summary: Make a custom variant type for PacketHeader. By not relying on boost::variant this reduces the code size of the implementation. This uses a combination of a union type as well as a enum type to emulate a variant Reviewed By: yangchi Differential Revision: D17187589 fbshipit-source-id: 00c2b9b8dd3f3e73af766d84888b13b9d867165a
This commit is contained in:
committed by
Facebook Github Bot
parent
c8da36d755
commit
04baa15a04
@@ -444,12 +444,9 @@ bool CryptoStreamScheduler::writeCryptoData(PacketBuilderInterface& builder) {
|
||||
}
|
||||
}
|
||||
if (cryptoDataWritten && conn_.nodeType == QuicNodeType::Client) {
|
||||
bool initialPacket = folly::variant_match(
|
||||
builder.getPacketHeader(),
|
||||
[](const LongHeader& header) {
|
||||
return header.getHeaderType() == LongHeader::Types::Initial;
|
||||
},
|
||||
[](const auto&) { return false; });
|
||||
const LongHeader* longHeader = builder.getPacketHeader().asLong();
|
||||
bool initialPacket =
|
||||
longHeader && longHeader->getHeaderType() == LongHeader::Types::Initial;
|
||||
if (initialPacket) {
|
||||
// This is the initial packet, we need to fill er up.
|
||||
while (builder.remainingSpaceInPkt() > 0) {
|
||||
@@ -521,9 +518,7 @@ CloningScheduler::scheduleFramesForPacket(
|
||||
for (auto iter = conn_.outstandingPackets.rbegin();
|
||||
iter != conn_.outstandingPackets.rend();
|
||||
++iter) {
|
||||
auto opPnSpace = folly::variant_match(
|
||||
iter->packet.header,
|
||||
[](const auto& h) { return h.getPacketNumberSpace(); });
|
||||
auto opPnSpace = iter->packet.header.getPacketNumberSpace();
|
||||
if (opPnSpace != PacketNumberSpace::AppData) {
|
||||
continue;
|
||||
}
|
||||
@@ -532,9 +527,7 @@ CloningScheduler::scheduleFramesForPacket(
|
||||
// clone packet. So re-create a RegularQuicPacketBuilder every time.
|
||||
// TODO: We can avoid the copy & rebuild of the header by creating an
|
||||
// independent header builder.
|
||||
auto builderPnSpace = folly::variant_match(
|
||||
builder.getPacketHeader(),
|
||||
[](const auto& h) { return h.getPacketNumberSpace(); });
|
||||
auto builderPnSpace = builder.getPacketHeader().getPacketNumberSpace();
|
||||
CHECK_EQ(builderPnSpace, PacketNumberSpace::AppData);
|
||||
RegularQuicPacketBuilder regularBuilder(
|
||||
conn_.udpSendPacketLen,
|
||||
|
||||
Reference in New Issue
Block a user