diff --git a/servo/components/style/driver.rs b/servo/components/style/driver.rs index e8dfe7cf3db3..aa39f3482f45 100644 --- a/servo/components/style/driver.rs +++ b/servo/components/style/driver.rs @@ -89,7 +89,7 @@ pub fn traverse_dom( // ThreadLocalStyleContext on the main thread. If the main thread // ThreadLocalStyleContext has not released its TLS borrow by that point, // we'll panic on double-borrow. - let mut maybe_tls: Option>> = None; + let mut tls_slots = None; let mut tlc = ThreadLocalStyleContext::new(traversal.shared_context()); let mut context = StyleContext { shared: traversal.shared_context(), @@ -129,7 +129,7 @@ pub fn traverse_dom( // depth for all the children. if pool.is_some() && discovered.len() > WORK_UNIT_MAX { let pool = pool.unwrap(); - maybe_tls = Some(ScopedTLS::>::new(pool)); + let tls = ScopedTLS::>::new(pool); let root_opaque = root.as_node().opaque(); let drain = discovered.drain(..); pool.install(|| { @@ -151,10 +151,12 @@ pub fn traverse_dom( scope, pool, traversal, - maybe_tls.as_ref().unwrap(), + &tls, ); }); }); + + tls_slots = Some(tls.into_slots()); break; } nodes_remaining_at_current_depth = discovered.len(); @@ -164,9 +166,9 @@ pub fn traverse_dom( // Collect statistics from thread-locals if requested. 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(tls) = maybe_tls { - for mut slot in tls.into_slots().into_vec() { + let parallel = tls_slots.is_some(); + if let Some(ref mut tls) = tls_slots { + for slot in tls.iter_mut() { if let Some(cx) = slot.get_mut() { aggregate += cx.statistics.clone(); } diff --git a/servo/components/style/values/computed/font.rs b/servo/components/style/values/computed/font.rs index a0c4ad695db7..0f821123c203 100644 --- a/servo/components/style/values/computed/font.rs +++ b/servo/components/style/values/computed/font.rs @@ -714,10 +714,7 @@ impl FontLanguageOverride { /// Returns this value as a `&str`, backed by `storage`. #[inline] - pub fn to_str(self, storage: &mut [u8; 4]) -> &str { - if self.0 == 0 { - return "normal"; - } + pub(crate) fn to_str(self, storage: &mut [u8; 4]) -> &str { *storage = u32::to_be_bytes(self.0); // Safe because we ensure it's ASCII during computing let slice = if cfg!(debug_assertions) { @@ -758,6 +755,9 @@ impl ToCss for FontLanguageOverride { where W: fmt::Write, { + if self.0 == 0 { + return dest.write_str("normal"); + } self.to_str(&mut [0; 4]).to_css(dest) } }