From 3e688d2a9340e8d8ca2da5bbdc441f2d6cce893c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 20 Jul 2020 18:01:42 +0200 Subject: Simplify --- crates/vfs/src/loader.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crates/vfs') 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 { self.includes_path(path) } fn includes_path(&self, path: &AbsPath) -> bool { - let mut include = None; + let mut include: Option<&AbsPathBuf> = None; for incl in &self.include { - if is_prefix(incl, path) { + if path.starts_with(incl) { include = Some(match include { - Some(prev) if is_prefix(incl, prev) => prev, + Some(prev) if prev.starts_with(incl) => prev, _ => incl, }) } @@ -97,15 +97,11 @@ impl Directories { None => return false, }; for excl in &self.exclude { - if is_prefix(excl, path) && is_prefix(include, excl) { + if path.starts_with(excl) && excl.starts_with(include) { return false; } } - return true; - - fn is_prefix(short: &AbsPath, long: &AbsPath) -> bool { - long.strip_prefix(short).is_some() - } + true } } -- cgit v1.2.3