mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Shrink maps if needed after stylist rebuilds
Hashbrown grows a lot sometimes making us waste a lot of memory. Shrink some of these maps after CascadeData rebuild / stylesheet collection invalidation. Differential Revision: https://phabricator.services.mozilla.com/D134716
This commit is contained in:
parent
f9610e5898
commit
fcc55f2156
6 changed files with 122 additions and 17 deletions
|
@ -11,7 +11,7 @@ use crate::selector_map::{
|
|||
};
|
||||
use crate::selector_parser::SelectorImpl;
|
||||
use crate::AllocErr;
|
||||
use crate::{Atom, LocalName, Namespace};
|
||||
use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded};
|
||||
use selectors::attr::NamespaceConstraint;
|
||||
use selectors::parser::{Combinator, Component};
|
||||
use selectors::parser::{Selector, SelectorIter};
|
||||
|
@ -237,6 +237,14 @@ impl InvalidationMap {
|
|||
self.other_attribute_affecting_selectors.clear();
|
||||
}
|
||||
|
||||
/// Shrink the capacity of hash maps if needed.
|
||||
pub fn shrink_if_needed(&mut self) {
|
||||
self.class_to_selector.shrink_if_needed();
|
||||
self.id_to_selector.shrink_if_needed();
|
||||
self.state_affecting_selectors.shrink_if_needed();
|
||||
self.other_attribute_affecting_selectors.shrink_if_needed();
|
||||
}
|
||||
|
||||
/// Adds a selector to this `InvalidationMap`. Returns Err(..) to
|
||||
/// signify OOM.
|
||||
pub fn note_selector(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue