1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-12-24 09:40:59 +03:00

Emplace packet directly into outstandingPackets

Summary: There's no reason for creating a temporary here just to then later emplace it into outstandingPackets.

Reviewed By: yangchi

Differential Revision: D19069802

fbshipit-source-id: 4505ed414a80b24ecd0111fedc21714412fa8c53
This commit is contained in:
Matt Joras
2019-12-18 21:01:25 -08:00
committed by Facebook Github Bot
parent da09e6c2a4
commit d4ac4ea8de

View File

@@ -353,7 +353,17 @@ void updateConnection(
DCHECK(!packetEvent);
return;
}
OutstandingPacket pkt(
auto packetIt =
std::find_if(
conn.outstandingPackets.rbegin(),
conn.outstandingPackets.rend(),
[packetNum](const auto& packetWithTime) {
return packetWithTime.packet.header.getPacketSequenceNum() <
packetNum;
})
.base();
auto& pkt = *conn.outstandingPackets.emplace(
packetIt,
std::move(packet),
std::move(sentTime),
encodedSize,
@@ -409,17 +419,6 @@ void updateConnection(
++conn.lossState.timeoutBasedRtxCount;
}
auto packetIt =
std::find_if(
conn.outstandingPackets.rbegin(),
conn.outstandingPackets.rend(),
[packetNum](const auto& packetWithTime) {
return packetWithTime.packet.header.getPacketSequenceNum() <
packetNum;
})
.base();
conn.outstandingPackets.insert(packetIt, std::move(pkt));
auto opCount = conn.outstandingPackets.size();
DCHECK_GE(opCount, conn.outstandingHandshakePacketsCount);
DCHECK_GE(opCount, conn.outstandingClonedPacketsCount);