diff --git a/TODO.md b/TODO.md index b8cf520..69da5a2 100644 --- a/TODO.md +++ b/TODO.md @@ -2,8 +2,9 @@ * Configuration, cli * Tests -* Optimize extract_response_peers -* Clean connections: `state.connections.shrink_to_fit()`? +* extract_response_peers + * Cleaner code + * Stack-allocated vector? ## Don't do diff --git a/aquatic/src/lib/tasks.rs b/aquatic/src/lib/tasks.rs index 403311a..9a6bd27 100644 --- a/aquatic/src/lib/tasks.rs +++ b/aquatic/src/lib/tasks.rs @@ -8,6 +8,7 @@ pub fn clean_connections(state: &State){ let limit = Instant::now() - Duration::from_secs(300); 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() }); + + state.torrents.shrink_to_fit(); } \ No newline at end of file