optimize common case of previously seen simple selectors
This commit is contained in:
parent
87b18e321f
commit
ca861d488b
@ -912,10 +912,17 @@ impl Extender {
|
|||||||
for component in complex.components {
|
for component in complex.components {
|
||||||
if let ComplexSelectorComponent::Compound(component) = component {
|
if let ComplexSelectorComponent::Compound(component) = component {
|
||||||
for simple in component.components {
|
for simple in component.components {
|
||||||
self.selectors
|
// PERF: we compute the hash twice, which isn't great, but we avoid a superfluous
|
||||||
.entry(simple.clone())
|
// clone in cases where we have already seen a simple selector (common in
|
||||||
.or_insert_with(SelectorHashSet::new)
|
// scenarios in which there is a lot of nesting)
|
||||||
.insert(selector.clone());
|
if let Some(entry) = self.selectors.get_mut(&simple) {
|
||||||
|
entry.insert(selector.clone())
|
||||||
|
} else {
|
||||||
|
self.selectors
|
||||||
|
.entry(simple.clone())
|
||||||
|
.or_insert_with(SelectorHashSet::new)
|
||||||
|
.insert(selector.clone());
|
||||||
|
}
|
||||||
|
|
||||||
if let SimpleSelector::Pseudo(Pseudo {
|
if let SimpleSelector::Pseudo(Pseudo {
|
||||||
selector: Some(simple_selector),
|
selector: Some(simple_selector),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user