Tiny optimisation

This commit is contained in:
Igor Katson 2024-04-15 20:33:51 +01:00
parent 2a4d9a85d5
commit 96ae960070
3 changed files with 6 additions and 1 deletions

View file

@ -190,6 +190,7 @@ impl ChunkTracker {
file_priorities
.iter()
.filter_map(|p| opened_files.get(*p))
.filter(|f| !f.approx_is_finished())
.flat_map(|f| f.iter_piece_priorities())
.filter(|id| self.queue_pieces[*id])
}

View file

@ -109,6 +109,10 @@ impl OpenedFile {
size
}
pub fn approx_is_finished(&self) -> bool {
self.have.load(Ordering::Relaxed) == self.len
}
pub fn iter_piece_priorities(&self) -> impl Iterator<Item = usize> {
iter_piece_priorities(self.piece_range_usize())
}

View file

@ -35,7 +35,7 @@ struct Opts {
log_file: Option<String>,
/// The value for RUST_LOG in the log file
#[arg(long = "log-file-rust-log", default_value = "librqbit=trace,info")]
#[arg(long = "log-file-rust-log", default_value = "librqbit=debug,info")]
log_file_rust_log: String,
/// The interval to poll trackers, e.g. 30s.