aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-05-26 07:25:58 -0500
committerbors-servo <lbergstrom+bors@mozilla.com>2016-05-26 07:25:58 -0500
commit2acb257a82601ad9b48a544cff20ce83f6311a47 (patch)
tree08c344c66f7ee46c2661112ffadb3d68985865de
parent7040e2a5f7c71699fcb7d48016ee8f1ab7bef73c (diff)
parentf967d5a64501dc924b1ad738b837ad9858393eb9 (diff)
downloadservo-2acb257a82601ad9b48a544cff20ce83f6311a47.tar.gz
servo-2acb257a82601ad9b48a544cff20ce83f6311a47.zip
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 -->
-rw-r--r--components/gfx/display_list/mod.rs13
-rw-r--r--tests/unit/layout/size_of.rs2
2 files changed, 8 insertions, 7 deletions
diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs
index 73071d91ec0..091e9a08c5a 100644
--- a/components/gfx/display_list/mod.rs
+++ b/components/gfx/display_list/mod.rs
@@ -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)
}
}
diff --git a/tests/unit/layout/size_of.rs b/tests/unit/layout/size_of.rs
index 87f1dcb3d44..033916647ee 100644
--- a/tests/unit/layout/size_of.rs
+++ b/tests/unit/layout/size_of.rs
@@ -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 {