diff options
author | Nick Young <nick@nickwb.net> | 2019-09-15 00:23:53 +1000 |
---|---|---|
committer | Kevin Song <chipbuster@users.noreply.github.com> | 2019-09-14 09:23:53 -0500 |
commit | 7e891f17c1c6f59f7a8be18e83927271f307dd3d (patch) | |
tree | 1ef229d198f7f0183f8f6ae4467b14fd8dc89f66 /src/modules | |
parent | 8f03c14582ad61bf4f95a6b69642d8052002d03d (diff) |
perf: Lazy load files from directory (#335)
Changes context to use `once_cell` to lazily evaluate directory listing on first use.
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/golang.rs | 4 | ||||
-rw-r--r-- | src/modules/nodejs.rs | 4 | ||||
-rw-r--r-- | src/modules/python.rs | 4 | ||||
-rw-r--r-- | src/modules/ruby.rs | 4 | ||||
-rw-r--r-- | src/modules/rust.rs | 4 | ||||
-rw-r--r-- | src/modules/time.rs | 4 |
6 files changed, 12 insertions, 12 deletions
diff --git a/src/modules/golang.rs b/src/modules/golang.rs index 4676f9e6d..9bbf0c16b 100644 --- a/src/modules/golang.rs +++ b/src/modules/golang.rs @@ -15,11 +15,11 @@ use super::{Context, Module}; /// - Current directory contains a file with the `.go` extension pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let is_go_project = context - .new_scan_dir() + .try_begin_scan()? .set_files(&["go.mod", "go.sum", "glide.yaml", "Gopkg.yml", "Gopkg.lock"]) .set_extensions(&["go"]) .set_folders(&["Godeps"]) - .scan(); + .is_match(); if !is_go_project { return None; diff --git a/src/modules/nodejs.rs b/src/modules/nodejs.rs index 180e143ff..b30f2f531 100644 --- a/src/modules/nodejs.rs +++ b/src/modules/nodejs.rs @@ -11,11 +11,11 @@ use super::{Context, Module}; /// - Current directory contains a `node_modules` directory pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let is_js_project = context - .new_scan_dir() + .try_begin_scan()? .set_files(&["package.json"]) .set_extensions(&["js"]) .set_folders(&["node_modules"]) - .scan(); + .is_match(); if !is_js_project { return None; diff --git a/src/modules/python.rs b/src/modules/python.rs index 487d033d5..84ca0e7e8 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -16,7 +16,7 @@ use super::{Context, Module}; /// - Current directory contains a `Pipfile` file pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let is_py_project = context - .new_scan_dir() + .try_begin_scan()? .set_files(&[ "requirements.txt", ".python-version", @@ -24,7 +24,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { "Pipfile", ]) .set_extensions(&["py"]) - .scan(); + .is_match(); if !is_py_project { return None; diff --git a/src/modules/ruby.rs b/src/modules/ruby.rs index 7e689234d..0faa2ccf8 100644 --- a/src/modules/ruby.rs +++ b/src/modules/ruby.rs @@ -10,10 +10,10 @@ use super::{Context, Module}; /// - Current directory contains a `Gemfile` file pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let is_rb_project = context - .new_scan_dir() + .try_begin_scan()? .set_files(&["Gemfile"]) .set_extensions(&["rb"]) - .scan(); + .is_match(); if !is_rb_project { return None; diff --git a/src/modules/rust.rs b/src/modules/rust.rs index 26ee377c9..2008a539d 100644 --- a/src/modules/rust.rs +++ b/src/modules/rust.rs @@ -10,10 +10,10 @@ use super::{Context, Module}; /// - Current directory contains a `Cargo.toml` file pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { let is_rs_project = context - .new_scan_dir() + .try_begin_scan()? .set_files(&["Cargo.toml"]) .set_extensions(&["rs"]) - .scan(); + .is_match(); if !is_rs_project { return None; diff --git a/src/modules/time.rs b/src/modules/time.rs index 0450e86fe..61a68c724 100644 --- a/src/modules/time.rs +++ b/src/modules/time.rs @@ -41,8 +41,8 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> { /// Format a given time into the given string. This function should be referentially /// transparent, which makes it easy to test (unlike anything involving the actual time) -fn format_time(time_format: &str, localtime: DateTime<Local>) -> String { - localtime.format(time_format).to_string() +fn format_time(time_format: &str, local_time: DateTime<Local>) -> String { + local_time.format(time_format).to_string() } /* Because we cannot make acceptance tests for the time module, these unit |