mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Avoid some allocations in selector serialization.
The allocations in display_to_css_identifier show up in the profiles of bug 1675628. Differential Revision: https://phabricator.services.mozilla.com/D97856
This commit is contained in:
parent
4ea378a6ae
commit
9f40b9ba38
19 changed files with 220 additions and 114 deletions
|
@ -17,6 +17,7 @@ use crate::selector_parser::{SelectorImpl, Snapshot, SnapshotMap};
|
|||
use crate::shared_lock::SharedRwLockReadGuard;
|
||||
use crate::stylesheets::{CssRule, StylesheetInDocument};
|
||||
use crate::stylesheets::{EffectiveRules, EffectiveRulesIterator};
|
||||
use crate::values::AtomIdent;
|
||||
use crate::Atom;
|
||||
use crate::LocalName as SelectorLocalName;
|
||||
use selectors::parser::{Component, LocalName, Selector};
|
||||
|
@ -43,9 +44,9 @@ pub enum RuleChangeKind {
|
|||
#[derive(Debug, Eq, Hash, MallocSizeOf, PartialEq)]
|
||||
enum Invalidation {
|
||||
/// An element with a given id.
|
||||
ID(Atom),
|
||||
ID(AtomIdent),
|
||||
/// An element with a given class name.
|
||||
Class(Atom),
|
||||
Class(AtomIdent),
|
||||
/// An element with a given local name.
|
||||
LocalName {
|
||||
name: SelectorLocalName,
|
||||
|
@ -468,14 +469,14 @@ impl StylesheetInvalidationSet {
|
|||
) -> bool {
|
||||
match invalidation {
|
||||
Invalidation::Class(c) => {
|
||||
let entry = match self.classes.try_entry(c, quirks_mode) {
|
||||
let entry = match self.classes.try_entry(c.0, quirks_mode) {
|
||||
Ok(e) => e,
|
||||
Err(..) => return false,
|
||||
};
|
||||
*entry.or_insert(InvalidationKind::None) |= kind;
|
||||
},
|
||||
Invalidation::ID(i) => {
|
||||
let entry = match self.ids.try_entry(i, quirks_mode) {
|
||||
let entry = match self.ids.try_entry(i.0, quirks_mode) {
|
||||
Ok(e) => e,
|
||||
Err(..) => return false,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue