layout: Simplify layout debugging scope.

This commit is contained in:
Emilio Cobos Álvarez 2016-12-25 17:36:24 +01:00
parent 39e082af18
commit cd00d65ffd
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -65,13 +65,10 @@ struct State {
impl Scope {
pub fn new(name: String) -> Scope {
STATE_KEY.with(|ref r| {
match *r.borrow_mut() {
Some(ref mut state) => {
let flow_trace = to_value(&flow::base(&*state.flow_root));
let data = box ScopeData::new(name.clone(), flow_trace);
state.scope_stack.push(data);
}
None => {}
if let Some(ref mut state) = *r.borrow_mut() {
let flow_trace = to_value(&flow::base(&*state.flow_root));
let data = box ScopeData::new(name.clone(), flow_trace);
state.scope_stack.push(data);
}
});
Scope
@ -82,14 +79,11 @@ impl Scope {
impl Drop for Scope {
fn drop(&mut self) {
STATE_KEY.with(|ref r| {
match *r.borrow_mut() {
Some(ref mut state) => {
let mut current_scope = state.scope_stack.pop().unwrap();
current_scope.post = to_value(&flow::base(&*state.flow_root));
let previous_scope = state.scope_stack.last_mut().unwrap();
previous_scope.children.push(current_scope);
}
None => {}
if let Some(ref mut state) = *r.borrow_mut() {
let mut current_scope = state.scope_stack.pop().unwrap();
current_scope.post = to_value(&flow::base(&*state.flow_root));
let previous_scope = state.scope_stack.last_mut().unwrap();
previous_scope.children.push(current_scope);
}
});
}