Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reduce the size of StackingContextId
  • Loading branch information
mbrubeck committed May 24, 2016
1 parent ea38ccf commit f967d5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions components/gfx/display_list/mod.rs
Expand Up @@ -1409,20 +1409,21 @@ pub enum FragmentType {
/// A unique ID for every stacking context.
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, PartialEq, RustcEncodable, Serialize)]
pub struct StackingContextId(
/// The type of the fragment for this StackingContext. This serves to differentiate
/// StackingContexts that share fragments.
FragmentType,
/// The identifier for this StackingContexts, derived from the Flow's memory address.
/// The identifier for this StackingContext, derived from the Flow's memory address
/// and fragment type. As a space optimization, these are combined into a single word.
usize
);

impl StackingContextId {
#[inline(always)]
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 {
StackingContextId(fragment_type, id)
debug_assert_eq!(id & fragment_type as usize, 0);
StackingContextId(id | fragment_type as usize)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/layout/size_of.rs
Expand Up @@ -8,7 +8,7 @@ use std::mem::size_of;

#[test]
fn test_size_of_fragment() {
let expected = 168;
let expected = 160;
let actual = size_of::<Fragment>();

if actual < expected {
Expand Down

0 comments on commit f967d5a

Please sign in to comment.