mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45:30 +00:00
cleaning tasks: run shrink_to_fit on connection and torrent maps
This commit is contained in:
parent
70b5795818
commit
d601025286
2 changed files with 6 additions and 2 deletions
5
TODO.md
5
TODO.md
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
* Configuration, cli
|
* Configuration, cli
|
||||||
* Tests
|
* Tests
|
||||||
* Optimize extract_response_peers
|
* extract_response_peers
|
||||||
* Clean connections: `state.connections.shrink_to_fit()`?
|
* Cleaner code
|
||||||
|
* Stack-allocated vector?
|
||||||
|
|
||||||
## Don't do
|
## Don't do
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ pub fn clean_connections(state: &State){
|
||||||
let limit = Instant::now() - Duration::from_secs(300);
|
let limit = Instant::now() - Duration::from_secs(300);
|
||||||
|
|
||||||
state.connections.retain(|_, v| v.0 > limit);
|
state.connections.retain(|_, v| v.0 > limit);
|
||||||
|
state.connections.shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,4 +39,6 @@ pub fn clean_torrents(state: &State){
|
||||||
|
|
||||||
!torrent.peers.is_empty()
|
!torrent.peers.is_empty()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
state.torrents.shrink_to_fit();
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue