summaryrefslogtreecommitdiffstats
path: root/src/git_ignore.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-01-30 22:32:06 +0100
committerCanop <cano.petrole@gmail.com>2020-01-30 22:32:06 +0100
commitb10cc444d58cb617c820f4a98d7a6e3d2bd09b46 (patch)
tree16df4c47579006ae6589c649ab385c7d72fbe297 /src/git_ignore.rs
parent29eeafe2c8b9388b74a904af2f20377731f5cb73 (diff)
add the time! macro
To help manage duration logging with reduced impact when not logging
Diffstat (limited to 'src/git_ignore.rs')
-rw-r--r--src/git_ignore.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/git_ignore.rs b/src/git_ignore.rs
index b91178d..19d3161 100644
--- a/src/git_ignore.rs
+++ b/src/git_ignore.rs
@@ -12,7 +12,6 @@ use {
fs::File,
io::{BufRead, BufReader, Result},
path::Path,
- time::Instant,
},
};
@@ -76,7 +75,6 @@ pub struct GitIgnoreFile {
}
impl GitIgnoreFile {
pub fn new(path: &Path) -> Result<GitIgnoreFile> {
- let start = Instant::now();
let f = File::open(path)?;
let parent = path.parent().unwrap();
let mut rules: Vec<GitIgnoreRule> = Vec::new();
@@ -89,10 +87,9 @@ impl GitIgnoreFile {
// we reverse the list to easily iterate from the last one to the first one
rules.reverse();
debug!(
- "loaded .gitignore file {:?} with {} rules in {:?}",
+ "loaded .gitignore file {:?} with {} rules",
path,
rules.len(),
- start.elapsed(),
);
Ok(GitIgnoreFile { rules })
}
@@ -109,7 +106,13 @@ pub fn find_global_ignore() -> Option<GitIgnoreFile> {
global_conf.get_path("core.excludesfile")
.ok()
.as_ref()
- .and_then(|path| GitIgnoreFile::new(path).ok())
+ .and_then(
+ |path| time!(
+ Debug,
+ "GitIgnoreFile::new",
+ GitIgnoreFile::new(path)
+ ).ok()
+ )
}
#[derive(Debug, Clone, Default)]
@@ -127,13 +130,11 @@ pub struct GitIgnorer {
}
impl GitIgnorer {
pub fn new() -> Self {
- let start = Instant::now();
let mut files = Arena::new();
let mut global_chain = GitIgnoreChain::default();
if let Some(gif) = find_global_ignore() {
global_chain.push(files.alloc(gif));
}
- debug!("git_ignorer init took {:?}", start.elapsed());
Self {
files,
global_chain,