mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-15 13:52:59 +00:00
Chore: use short-circuiting for file ID getter
This commit is contained in:
parent
8e4fb4f518
commit
e912d6507f
@ -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…
x
Reference in New Issue
Block a user