mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #11394 - mbrubeck:stacking-context-id, r=pcwalton
Reduce the size of StackingContextId r? @pcwalton <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11394) <!-- Reviewable:end -->
This commit is contained in:
commit
2acb257a82
2 changed files with 8 additions and 7 deletions
|
@ -1409,20 +1409,21 @@ pub enum FragmentType {
|
||||||
/// A unique ID for every stacking context.
|
/// A unique ID for every stacking context.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, RustcEncodable, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, RustcEncodable, Serialize)]
|
||||||
pub struct StackingContextId(
|
pub struct StackingContextId(
|
||||||
/// The type of the fragment for this StackingContext. This serves to differentiate
|
/// The identifier for this StackingContext, derived from the Flow's memory address
|
||||||
/// StackingContexts that share fragments.
|
/// and fragment type. As a space optimization, these are combined into a single word.
|
||||||
FragmentType,
|
|
||||||
/// The identifier for this StackingContexts, derived from the Flow's memory address.
|
|
||||||
usize
|
usize
|
||||||
);
|
);
|
||||||
|
|
||||||
impl StackingContextId {
|
impl StackingContextId {
|
||||||
|
#[inline(always)]
|
||||||
pub fn new(id: usize) -> StackingContextId {
|
pub fn new(id: usize) -> StackingContextId {
|
||||||
StackingContextId(FragmentType::FragmentBody, id)
|
StackingContextId::new_of_type(id, FragmentType::FragmentBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
pub fn new_of_type(id: usize, fragment_type: FragmentType) -> StackingContextId {
|
pub fn new_of_type(id: usize, fragment_type: FragmentType) -> StackingContextId {
|
||||||
StackingContextId(fragment_type, id)
|
debug_assert_eq!(id & fragment_type as usize, 0);
|
||||||
|
StackingContextId(id | fragment_type as usize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::mem::size_of;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_size_of_fragment() {
|
fn test_size_of_fragment() {
|
||||||
let expected = 168;
|
let expected = 160;
|
||||||
let actual = size_of::<Fragment>();
|
let actual = size_of::<Fragment>();
|
||||||
|
|
||||||
if actual < expected {
|
if actual < expected {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue