mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
udp: TorrentMap cleaning: improve code, do less work
This commit is contained in:
parent
0f6be84576
commit
ebe612a560
1 changed files with 11 additions and 7 deletions
|
|
@ -98,9 +98,9 @@ impl TorrentMaps {
|
|||
let num_leechers = &mut torrent.num_leechers;
|
||||
|
||||
torrent.peers.retain(|_, peer| {
|
||||
let keep = peer.valid_until.0 > now;
|
||||
|
||||
if !keep {
|
||||
if peer.valid_until.0 > now {
|
||||
true
|
||||
} else {
|
||||
match peer.status {
|
||||
PeerStatus::Seeding => {
|
||||
*num_seeders -= 1;
|
||||
|
|
@ -110,14 +110,18 @@ impl TorrentMaps {
|
|||
}
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
|
||||
keep
|
||||
false
|
||||
}
|
||||
});
|
||||
|
||||
torrent.peers.shrink_to_fit();
|
||||
if torrent.peers.is_empty() {
|
||||
false
|
||||
} else {
|
||||
torrent.peers.shrink_to_fit();
|
||||
|
||||
!torrent.peers.is_empty()
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue