mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45: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;
|
let num_leechers = &mut torrent.num_leechers;
|
||||||
|
|
||||||
torrent.peers.retain(|_, peer| {
|
torrent.peers.retain(|_, peer| {
|
||||||
let keep = peer.valid_until.0 > now;
|
if peer.valid_until.0 > now {
|
||||||
|
true
|
||||||
if !keep {
|
} else {
|
||||||
match peer.status {
|
match peer.status {
|
||||||
PeerStatus::Seeding => {
|
PeerStatus::Seeding => {
|
||||||
*num_seeders -= 1;
|
*num_seeders -= 1;
|
||||||
|
|
@ -110,14 +110,18 @@ impl TorrentMaps {
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
keep
|
false
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if torrent.peers.is_empty() {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
torrent.peers.shrink_to_fit();
|
torrent.peers.shrink_to_fit();
|
||||||
|
|
||||||
!torrent.peers.is_empty()
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue