summaryrefslogtreecommitdiffstats
path: root/globset
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-04-24 10:42:19 -0400
committerAndrew Gallant <jamslam@gmail.com>2018-04-24 11:19:03 -0400
commitab64da73ab3f73f50192459dfc1e49c6cabd9de8 (patch)
tree783fb638506f87a1459f194f1baebab85f2c1511 /globset
parent1266de3d4c82f281642ba0f4b59827091a55c8fc (diff)
ignore: speed up Gitignore::empty
This commit makes Gitignore::empty a bit faster by avoiding allocation and manually specializing the implementation instead of routing it through the GitignoreBuilder. This helps improve uses of ripgrep that traverse *many* directories, and in particular, when the use of ignores is disabled via command line switches. Fixes #835, Closes #836
Diffstat (limited to 'globset')
-rw-r--r--globset/src/lib.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/globset/src/lib.rs b/globset/src/lib.rs
index eabed515..50c92e42 100644
--- a/globset/src/lib.rs
+++ b/globset/src/lib.rs
@@ -288,6 +288,14 @@ pub struct GlobSet {
}
impl GlobSet {
+ /// Create an empty `GlobSet`. An empty set matches nothing.
+ pub fn empty() -> GlobSet {
+ GlobSet {
+ len: 0,
+ strats: vec![],
+ }
+ }
+
/// Returns true if this set is empty, and therefore matches nothing.
pub fn is_empty(&self) -> bool {
self.len == 0