mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
b05ace3e4a
commit
62419adaaa
12 changed files with 96 additions and 50 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue