提交 ae2f2991 编写于 作者: B bors

Auto merge of #51203 - nnethercote:obligations-2, r=michaelwoerister

Two minor `obligation_forest` tweaks.

Pretty minimal improvements, but improvements nonetheless.
......@@ -75,9 +75,6 @@ pub struct ObligationForest<O: ForestObligation> {
done_cache: FxHashSet<O::Predicate>,
/// An cache of the nodes in `nodes`, indexed by predicate.
waiting_cache: FxHashMap<O::Predicate, NodeIndex>,
/// A list of the obligations added in snapshots, to allow
/// for their removal.
cache_list: Vec<O::Predicate>,
scratch: Option<Vec<usize>>,
}
......@@ -158,7 +155,6 @@ pub fn new() -> ObligationForest<O> {
nodes: vec![],
done_cache: FxHashSet(),
waiting_cache: FxHashMap(),
cache_list: vec![],
scratch: Some(vec![]),
}
}
......@@ -207,7 +203,6 @@ fn register_obligation_at(&mut self, obligation: O, parent: Option<NodeIndex>)
debug!("register_obligation_at({:?}, {:?}) - ok, new index is {}",
obligation, parent, self.nodes.len());
v.insert(NodeIndex::new(self.nodes.len()));
self.cache_list.push(obligation.as_predicate().clone());
self.nodes.push(Node::new(parent, obligation));
Ok(())
}
......
......@@ -17,11 +17,13 @@ pub struct NodeIndex {
}
impl NodeIndex {
#[inline]
pub fn new(value: usize) -> NodeIndex {
assert!(value < (u32::MAX as usize));
NodeIndex { index: NonZeroU32::new((value as u32) + 1).unwrap() }
}
#[inline]
pub fn get(self) -> usize {
(self.index.get() - 1) as usize
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册