mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-27 12:25:05 +00:00
Chore: use short-circuiting for file ID getter
This commit is contained in:
parent
8e4fb4f518
commit
e912d6507f
1 changed files with 3 additions and 1 deletions
|
@ -111,7 +111,9 @@ impl Vfs {
|
||||||
|
|
||||||
/// Id of the given path if it exists in the `Vfs` and is not deleted.
|
/// Id of the given path if it exists in the `Vfs` and is not deleted.
|
||||||
pub fn file_id(&self, path: &VfsPath) -> Option<FileId> {
|
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`.
|
/// File path corresponding to the given `file_id`.
|
||||||
|
|
Loading…
Reference in a new issue