Make Definitions::find_node_for_hir_id() a linear search instead of a binary one.
Unfortunately, the NodeId->HirId array is not sorted. Since this search is only done right before calling bug!(), let's not waste time allocating a faster lookup.
This commit is contained in:
parent
454533f5d9
commit
55e04d9c17
1 changed files with 5 additions and 1 deletions
|
|
@ -466,7 +466,11 @@ impl Definitions {
|
|||
}
|
||||
|
||||
pub fn find_node_for_hir_id(&self, hir_id: hir::HirId) -> ast::NodeId {
|
||||
self.node_to_hir_id.binary_search(&hir_id).unwrap()
|
||||
self.node_to_hir_id
|
||||
.iter()
|
||||
.position(|x| *x == hir_id)
|
||||
.map(|idx| ast::NodeId::new(idx))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
/// Add a definition with a parent definition.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue