Skip to content

Commit

Permalink
make the application more responsive on slow disks
Browse files Browse the repository at this point in the history
More frequent checks of task lifetime during builds.
The cost isn't so important, it's worth the change for
slow disk users when walking the whole disk.
  • Loading branch information
Canop committed Feb 4, 2019
1 parent 2317155 commit ec1434f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "broot"
version = "0.5.1"
version = "0.5.2"
authors = ["dystroy <[email protected]>"]
repository = "https://github.com/Canop/broot"
description = "Fuzzy Search + tree + cd"
Expand Down
8 changes: 5 additions & 3 deletions src/fuzzy_patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! It's not meant for file contents but for small strings (less than 1000 chars)
//! such as file names.
use std::fmt;
use std::fmt::{self, Write};
use crate::patterns::{Match};

// weights used in match score computing
Expand All @@ -21,8 +21,10 @@ pub struct FuzzyPattern {

impl fmt::Display for FuzzyPattern {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// TODO is there a clean and efficient way to display a [char] ?
write!(f, "{}", self.lc_chars.iter().collect::<String>())
for &c in self.lc_chars.iter() {
f.write_char(c)?
}
Ok(())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use crate::external::Launchable;
use crate::tree_options::TreeOptions;
use crate::verbs::VerbStore;

const VERSION: &str = "0.5.1";
const VERSION: &str = "0.5.2";

// declare the possible CLI arguments, and gets the values
fn get_cli_args<'a>() -> clap::ArgMatches<'a> {
Expand Down
8 changes: 6 additions & 2 deletions src/tree_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl TreeBuilder {
break;
}
if task_lifetime.is_expired() {
info!("task expired (core build)");
info!("task expired (core build - outer loop)");
return None;
}
} else if nb_lines_ok >= self.targeted_size {
Expand All @@ -374,6 +374,10 @@ impl TreeBuilder {
break;
}
for next_level_dir_idx in &next_level_dirs {
if self.options.pattern.is_some() && task_lifetime.is_expired() {
info!("task expired (core build - inner loop)");
return None;
}
let has_child_match = self.load_children(*next_level_dir_idx);
if has_child_match {
// we must ensure the ancestors are made Ok
Expand Down Expand Up @@ -486,7 +490,7 @@ impl TreeBuilder {

// build a tree. Can be called only once per builder
pub fn build(mut self, task_lifetime: &TaskLifetime) -> Option<Tree> {
debug!("start building with pattern {:?}", self.options.pattern);
debug!("start building with pattern {}", self.options.pattern);
match self.gather_lines(task_lifetime) {
Some(out_blines) => {
self.trim_excess(&out_blines);
Expand Down

0 comments on commit ec1434f

Please sign in to comment.