Inline reserve_node_ids

This function was only ever called with 1 so there's little point in it;
this isn't an expensive operation (essentially a checked add) so we're
not really "reserving" anything either.
This commit is contained in:
Mark Rousskov 2019-11-04 08:22:52 -05:00
parent dd6df0d20e
commit 43a74051c7

View File

@ -1236,20 +1236,12 @@ impl<'a> Resolver<'a> {
}
}
pub fn reserve_node_ids(&mut self, count: usize) -> ast::NodeId {
let id = self.next_node_id;
match id.as_usize().checked_add(count) {
Some(next) => {
self.next_node_id = ast::NodeId::from_usize(next);
}
None => panic!("input too large; ran out of node-IDs!"),
}
id
}
pub fn next_node_id(&mut self) -> NodeId {
self.reserve_node_ids(1)
let next = self.next_node_id.as_usize()
.checked_add(1)
.expect("input too large; ran out of NodeIds");
self.next_node_id = ast::NodeId::from_usize(next);
self.next_node_id
}
pub fn lint_buffer(&mut self) -> &mut lint::LintBuffer {