diff --git a/components/style/driver.rs b/components/style/driver.rs index 88ec933874e..e8dfe7cf3db 100644 --- a/components/style/driver.rs +++ b/components/style/driver.rs @@ -165,10 +165,9 @@ pub fn traverse_dom( if dump_stats || report_stats { let mut aggregate = mem::replace(&mut context.thread_local.statistics, Default::default()); let parallel = maybe_tls.is_some(); - if let Some(ref mut tls) = maybe_tls { - let slots = unsafe { tls.unsafe_get() }; - for slot in slots { - if let Some(ref cx) = *slot.borrow() { + if let Some(tls) = maybe_tls { + for mut slot in tls.into_slots().into_vec() { + if let Some(cx) = slot.get_mut() { aggregate += cx.statistics.clone(); } } diff --git a/components/style/scoped_tls.rs b/components/style/scoped_tls.rs index e1e5209a058..7491456669d 100644 --- a/components/style/scoped_tls.rs +++ b/components/style/scoped_tls.rs @@ -71,9 +71,8 @@ impl<'scope, T: Send> ScopedTLS<'scope, T> { RefMut::map(opt, |x| x.as_mut().unwrap()) } - /// Unsafe access to the slots. This can be used to access the TLS when - /// the caller knows that the pool does not have access to the TLS. - pub unsafe fn unsafe_get(&self) -> &[RefCell>] { - &self.slots + /// Returns the slots, consuming the scope. + pub fn into_slots(self) -> Box<[RefCell>]> { + self.slots } }