From e912d6507f38b98ce56fa1f44d1f52c0433fe8e6 Mon Sep 17 00:00:00 2001 From: Basti Ortiz <39114273+Some-Dood@users.noreply.github.com> Date: Tue, 10 Aug 2021 15:43:51 +0800 Subject: [PATCH] Chore: use short-circuiting for file ID getter --- crates/vfs/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs index e075d752b7ff..7828e51be934 100644 --- a/crates/vfs/src/lib.rs +++ b/crates/vfs/src/lib.rs @@ -111,7 +111,9 @@ pub fn len(&self) -> usize { /// Id of the given path if it exists in the `Vfs` and is not deleted. pub fn file_id(&self, path: &VfsPath) -> Option { - self.interner.get(path).filter(|&it| self.get(it).is_some()) + let it = self.interner.get(path)?; + let _ = self.get(it).as_ref()?; + Some(it) } /// File path corresponding to the given `file_id`.