style: Shrink selectors::Component to 24 bytes.

This saves about 37 KiB of memory across the UA style sheets.

Bug: 1475197
Reviewed-by: emilio
This commit is contained in:
Cameron McCormack 2018-07-16 12:15:47 +10:00 committed by Emilio Cobos Álvarez
parent b05ace3e4a
commit 62419adaaa
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
12 changed files with 96 additions and 50 deletions

View file

@ -63,6 +63,7 @@ extern crate smallbitvec;
extern crate smallvec;
#[cfg(feature = "servo")]
extern crate string_cache;
extern crate thin_slice;
#[cfg(feature = "servo")]
extern crate time;
#[cfg(feature = "url")]
@ -231,6 +232,24 @@ impl<T: MallocSizeOf + ?Sized> MallocSizeOf for Box<T> {
}
}
impl<T> MallocShallowSizeOf for thin_slice::ThinBoxedSlice<T> {
fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
let mut n = 0;
unsafe {
n += thin_slice::ThinBoxedSlice::spilled_storage(self)
.map_or(0, |ptr| ops.malloc_size_of(ptr));
n += ops.malloc_size_of(&**self);
}
n
}
}
impl<T: MallocSizeOf> MallocSizeOf for thin_slice::ThinBoxedSlice<T> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.shallow_size_of(ops) + (**self).size_of(ops)
}
}
impl MallocSizeOf for () {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0
@ -770,7 +789,7 @@ where
}
impl<Impl: selectors::parser::SelectorImpl> MallocSizeOf
for selectors::attr::AttrSelectorWithNamespace<Impl>
for selectors::attr::AttrSelectorWithOptionalNamespace<Impl>
{
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
0