avoid extra clone

This commit is contained in:
Niko Matsakis 2016-06-03 20:39:43 -04:00
parent 4038b5b3ee
commit af4a0e8e05

View File

@ -14,20 +14,20 @@ use super::thread::{DepGraphThreadData, DepMessage};
pub struct DepTask<'graph> {
data: &'graph DepGraphThreadData,
key: DepNode<DefId>,
key: Option<DepNode<DefId>>,
}
impl<'graph> DepTask<'graph> {
pub fn new(data: &'graph DepGraphThreadData, key: DepNode<DefId>)
-> DepTask<'graph> {
data.enqueue(DepMessage::PushTask(key.clone()));
DepTask { data: data, key: key }
DepTask { data: data, key: Some(key) }
}
}
impl<'graph> Drop for DepTask<'graph> {
fn drop(&mut self) {
self.data.enqueue(DepMessage::PopTask(self.key.clone()));
self.data.enqueue(DepMessage::PopTask(self.key.take().unwrap()));
}
}