mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #16874 - bholley:applicable_declarations_smallvec, r=emilio
Use a SmallVec when gathering applicable declarations https://bugzilla.mozilla.org/show_bug.cgi?id=1364952 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16874) <!-- Reviewable:end -->
This commit is contained in:
commit
7ca393a960
2 changed files with 16 additions and 9 deletions
|
@ -33,7 +33,7 @@ use selectors::parser::{SelectorMethods, LocalName as LocalNameSelector};
|
|||
use selectors::visitor::SelectorVisitor;
|
||||
use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
|
||||
use sink::Push;
|
||||
use smallvec::VecLike;
|
||||
use smallvec::{SmallVec, VecLike};
|
||||
use std::borrow::Borrow;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::Hash;
|
||||
|
@ -49,6 +49,15 @@ use viewport::{self, MaybeNew, ViewportRule};
|
|||
|
||||
pub use ::fnv::FnvHashMap;
|
||||
|
||||
/// List of applicable declaration. This is a transient structure that shuttles
|
||||
/// declarations between selector matching and inserting into the rule tree, and
|
||||
/// therefore we want to avoid heap-allocation where possible.
|
||||
///
|
||||
/// In measurements on wikipedia, we pretty much never have more than 8 applicable
|
||||
/// declarations, so we could consider making this 8 entries instead of 16.
|
||||
/// However, it may depend a lot on workload, and stack space is cheap.
|
||||
pub type ApplicableDeclarationList = SmallVec<[ApplicableDeclarationBlock; 16]>;
|
||||
|
||||
/// This structure holds all the selectors and device characteristics
|
||||
/// for a given document. The selectors are converted into `Rule`s
|
||||
/// (defined in rust-selectors), and introduced in a `SelectorMap`
|
||||
|
@ -678,7 +687,7 @@ impl Stylist {
|
|||
};
|
||||
|
||||
|
||||
let mut declarations = vec![];
|
||||
let mut declarations = ApplicableDeclarationList::new();
|
||||
self.push_applicable_declarations(element,
|
||||
None,
|
||||
None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue