]> git.lizzy.rs Git - rust.git/commitdiff
Simplify
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 20 Jul 2020 16:01:42 +0000 (18:01 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 20 Jul 2020 16:01:42 +0000 (18:01 +0200)
crates/vfs/src/loader.rs

index 9c6e4b6a7da697de968f0db41a899f08b49dfc39..04e257f53f866bf071bc0eb7ec3fcb6a19eeb835 100644 (file)
@@ -83,11 +83,11 @@ pub fn contains_dir(&self, path: &AbsPath) -> bool {
         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 @@ fn includes_path(&self, path: &AbsPath) -> bool {
             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
     }
 }