mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Avoid creating a vector in can_share_style_with.
This commit is contained in:
parent
e3440c8a59
commit
811ea395bc
1 changed files with 23 additions and 2 deletions
|
@ -20,6 +20,7 @@ use selectors::bloom::BloomFilter;
|
||||||
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
|
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
|
||||||
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
|
||||||
use selectors::parser::PseudoElement;
|
use selectors::parser::PseudoElement;
|
||||||
|
use selectors::smallvec::VecLike;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -289,9 +290,29 @@ impl StyleSharingCandidate {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut matching_rules = vec![];
|
struct RulesSink {
|
||||||
|
empty: bool,
|
||||||
|
}
|
||||||
|
impl<T> VecLike<T> for RulesSink {
|
||||||
|
#[inline]
|
||||||
|
fn vec_len(&self) -> usize {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn vec_push(&mut self, _value: T) {
|
||||||
|
self.empty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn vec_slice_mut<'a>(&'a mut self, _start: usize, _end: usize)
|
||||||
|
-> &'a mut [T] {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut matching_rules = RulesSink { empty: true };
|
||||||
element.synthesize_presentational_hints_for_legacy_attributes(&mut matching_rules);
|
element.synthesize_presentational_hints_for_legacy_attributes(&mut matching_rules);
|
||||||
if !matching_rules.is_empty() {
|
if !matching_rules.empty {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue