mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_common: possibly do less allocations in extract_response_peers
This commit is contained in:
parent
14a4c10546
commit
4560c7fce0
1 changed files with 6 additions and 3 deletions
|
|
@ -50,7 +50,9 @@ where
|
|||
let peer_map_len = peer_map.len();
|
||||
|
||||
if peer_map_len <= max_num_peers_to_take + 1 {
|
||||
peer_map
|
||||
let mut peers = Vec::with_capacity(peer_map_len);
|
||||
|
||||
peers.extend(peer_map
|
||||
.iter()
|
||||
.filter_map(|(k, v)| {
|
||||
if *k == sender_peer_map_key {
|
||||
|
|
@ -58,8 +60,9 @@ where
|
|||
} else {
|
||||
Some(peer_conversion_function(v))
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}));
|
||||
|
||||
peers
|
||||
} else {
|
||||
let half_num_to_take = max_num_peers_to_take / 2;
|
||||
let half_peer_map_len = peer_map_len / 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue