Chore: use short-circuiting for file ID getter

This commit is contained in:
Basti Ortiz 2021-08-10 15:43:51 +08:00
parent 8e4fb4f518
commit e912d6507f
No known key found for this signature in database
GPG key ID: 1402D5CB17F48E1B

View file

@ -111,7 +111,9 @@ impl Vfs {
/// Id of the given path if it exists in the `Vfs` and is not deleted.
pub fn file_id(&self, path: &VfsPath) -> Option<FileId> {
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`.