summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2019-02-04 18:22:09 +0100
committerCanop <cano.petrole@gmail.com>2019-02-04 18:22:09 +0100
commitec1434fe03b5d27fdf9f28cb22b90326788d5012 (patch)
tree1c77b7ffab58196f6a29c6cf36a149a31f4f945e
parent2317155e39ecfab5cd11c32e5dbed48fc8baa06b (diff)
make the application more responsive on slow disksv0.5.2
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.
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/fuzzy_patterns.rs8
-rw-r--r--src/main.rs2
-rw-r--r--src/tree_build.rs8
5 files changed, 14 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 001266d..0599bd8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -31,7 +31,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "broot"
-version = "0.5.1"
+version = "0.5.2"
dependencies = [
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"custom_error 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 9dc96c6..09d6333 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "broot"
-version = "0.5.1"
+version = "0.5.2"
authors = ["dystroy <denys.seguret@gmail.com>"]
repository = "https://github.com/Canop/broot"
description = "Fuzzy Search + tree + cd"
diff --git a/src/fuzzy_patterns.rs b/src/fuzzy_patterns.rs
index 29c7b84..08a03fe 100644
--- a/src/fuzzy_patterns.rs
+++ b/src/fuzzy_patterns.rs
@@ -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
@@ -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(())
}
}
diff --git a/src/main.rs b/src/main.rs
index c243981..67895a7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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> {
diff --git a/src/tree_build.rs b/src/tree_build.rs
index 625bbdd..44f517d 100644
--- a/src/tree_build.rs
+++ b/src/tree_build.rs
@@ -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 {
@@ -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
@@ -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);