stops consuming pinned vectors with a recycler (#16441)

If the vector is pinned and has a recycler, From<PinnedVec>
implementation of Vec should clone (instead of consuming) the underlying
vector so that the next allocation of a PinnedVec will recycle an
already pinned one.
This commit is contained in:
behzad nouri
2021-04-09 16:55:24 +00:00
committed by GitHub
parent 8ec7e2e14f
commit 22a18a68e3
4 changed files with 11 additions and 22 deletions

View File

@ -2816,7 +2816,7 @@ impl ClusterInfo {
let packets: Vec<_> = requests_receiver.recv_timeout(RECV_TIMEOUT)?.packets.into();
let mut packets = VecDeque::from(packets);
while let Ok(packet) = requests_receiver.try_recv() {
packets.extend(packet.packets.into_iter());
packets.extend(packet.packets.iter().cloned());
let excess_count = packets.len().saturating_sub(MAX_GOSSIP_TRAFFIC);
if excess_count > 0 {
packets.drain(0..excess_count);

View File

@ -59,7 +59,8 @@ impl VerifiedVotePackets {
}
let packets = votes
.into_iter()
.flat_map(|(_, (_, packets))| packets.packets.clone())
.flat_map(|(_, (_, packets))| &packets.packets)
.cloned()
.collect();
(new_update_version, Packets::new(packets))
}