diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index f251716b5e4..e42a4a8b19e 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -393,10 +393,10 @@ impl SharingCacheBase { } impl SharingCache { - fn insert(&mut self, el: E, validation_data: ValidationData) { + fn insert(&mut self, el: E, validation_data_holder: &mut StyleSharingTarget) { self.entries.insert(StyleSharingCandidate { element: el, - validation_data: validation_data, + validation_data: validation_data_holder.take_validation_data(), }); } @@ -495,10 +495,13 @@ impl StyleSharingCache { /// Tries to insert an element in the style sharing cache. /// /// Fails if we know it should never be in the cache. + /// + /// NB: We pass a source for the validation data, rather than the data itself, + /// to avoid memmoving at each function call. See rust issue #42763. pub fn insert_if_possible(&mut self, element: &E, style: &ComputedValues, - validation_data: ValidationData, + validation_data_holder: &mut StyleSharingTarget, dom_depth: usize) { let parent = match element.traversal_parent() { Some(element) => element, @@ -551,7 +554,7 @@ impl StyleSharingCache { self.clear(); self.dom_depth = dom_depth; } - self.cache_mut().insert(*element, validation_data); + self.cache_mut().insert(*element, validation_data_holder); } /// Clear the style sharing candidate cache. diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 9fb6be98a22..efe7d8f68b3 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -679,7 +679,7 @@ where .insert_if_possible( &element, new_styles.primary(), - target.take_validation_data(), + &mut target, context.thread_local.bloom_filter.matching_depth(), );