aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-20 17:01:42 +0100
committerAleksey Kladov <[email protected]>2020-07-20 17:01:42 +0100
commit3e688d2a9340e8d8ca2da5bbdc441f2d6cce893c (patch)
treedec88276e72c3e49f5946a16a1b01a163c34fe17 /crates
parentbc4d047267232db485e24f74c05ad03f76b1786b (diff)
Simplify
Diffstat (limited to 'crates')
-rw-r--r--crates/vfs/src/loader.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/vfs/src/loader.rs b/crates/vfs/src/loader.rs
index 9c6e4b6a7..04e257f53 100644
--- a/crates/vfs/src/loader.rs
+++ b/crates/vfs/src/loader.rs
@@ -83,11 +83,11 @@ impl Directories {
83 self.includes_path(path) 83 self.includes_path(path)
84 } 84 }
85 fn includes_path(&self, path: &AbsPath) -> bool { 85 fn includes_path(&self, path: &AbsPath) -> bool {
86 let mut include = None; 86 let mut include: Option<&AbsPathBuf> = None;
87 for incl in &self.include { 87 for incl in &self.include {
88 if is_prefix(incl, path) { 88 if path.starts_with(incl) {
89 include = Some(match include { 89 include = Some(match include {
90 Some(prev) if is_prefix(incl, prev) => prev, 90 Some(prev) if prev.starts_with(incl) => prev,
91 _ => incl, 91 _ => incl,
92 }) 92 })
93 } 93 }
@@ -97,15 +97,11 @@ impl Directories {
97 None => return false, 97 None => return false,
98 }; 98 };
99 for excl in &self.exclude { 99 for excl in &self.exclude {
100 if is_prefix(excl, path) && is_prefix(include, excl) { 100 if path.starts_with(excl) && excl.starts_with(include) {
101 return false; 101 return false;
102 } 102 }
103 } 103 }
104 return true; 104 true
105
106 fn is_prefix(short: &AbsPath, long: &AbsPath) -> bool {
107 long.strip_prefix(short).is_some()
108 }
109 } 105 }
110} 106}
111 107