aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/main/layout/flow.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-01-30 14:48:05 -0800
committerPatrick Walton <pcwalton@mimiga.net>2014-01-30 15:11:35 -0800
commita8e35fbeacf3cc2b8b689a402b04b70439a8d851 (patch)
treeabaac6df6c35164671a3dee8fc285c882df282e9 /src/components/main/layout/flow.rs
parent0dd37d9cd32eb08e68288d1b6c5349625bfab7d2 (diff)
downloadservo-a8e35fbeacf3cc2b8b689a402b04b70439a8d851.tar.gz
servo-a8e35fbeacf3cc2b8b689a402b04b70439a8d851.zip
layout: Use the concurrent hash map for the leaf sets.
64% improvement in style recalc.
Diffstat (limited to 'src/components/main/layout/flow.rs')
-rw-r--r--src/components/main/layout/flow.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/components/main/layout/flow.rs b/src/components/main/layout/flow.rs
index d47743fa897..2c2e43be011 100644
--- a/src/components/main/layout/flow.rs
+++ b/src/components/main/layout/flow.rs
@@ -44,10 +44,10 @@ use geom::rect::Rect;
use gfx::display_list::{ClipDisplayItemClass, DisplayList};
use layout::display_list_builder::ToGfxColor;
use gfx::color::Color;
+use servo_util::concurrentmap::{ConcurrentHashMap, ConcurrentHashMapIterator};
use servo_util::geometry::Au;
use std::cast;
use std::cell::RefCell;
-use std::hashmap::{HashSet, HashSetIterator};
use std::sync::atomics::Relaxed;
use style::ComputedValues;
use style::computed_values::text_align;
@@ -216,13 +216,13 @@ pub trait MutableOwnedFlowUtils {
/// Marks the flow as a leaf. The flow must not have children and must not be marked as a
/// nonleaf.
- fn mark_as_leaf(&mut self, leaf_set: &mut FlowLeafSet);
+ fn mark_as_leaf(&mut self, leaf_set: &FlowLeafSet);
/// Marks the flow as a nonleaf. The flow must not be marked as a leaf.
fn mark_as_nonleaf(&mut self);
/// Destroys the flow.
- fn destroy(&mut self, leaf_set: &mut FlowLeafSet);
+ fn destroy(&mut self, leaf_set: &FlowLeafSet);
}
pub enum FlowClass {
@@ -756,7 +756,7 @@ impl MutableOwnedFlowUtils for ~Flow {
/// Marks the flow as a leaf. The flow must not have children and must not be marked as a
/// nonleaf.
- fn mark_as_leaf(&mut self, leaf_set: &mut FlowLeafSet) {
+ fn mark_as_leaf(&mut self, leaf_set: &FlowLeafSet) {
{
let base = mut_base(*self);
if base.flags_info.flags.is_nonleaf() {
@@ -781,7 +781,7 @@ impl MutableOwnedFlowUtils for ~Flow {
}
/// Destroys the flow.
- fn destroy(&mut self, leaf_set: &mut FlowLeafSet) {
+ fn destroy(&mut self, leaf_set: &FlowLeafSet) {
let is_leaf = {
let base = mut_base(*self);
base.children.len() == 0
@@ -802,27 +802,26 @@ impl MutableOwnedFlowUtils for ~Flow {
/// Keeps track of the leaves of the flow tree. This is used to efficiently start bottom-up
/// parallel traversals.
-#[deriving(Clone)]
pub struct FlowLeafSet {
- priv set: HashSet<UnsafeFlow>,
+ priv set: ConcurrentHashMap<UnsafeFlow,()>,
}
impl FlowLeafSet {
/// Creates a new flow leaf set.
pub fn new() -> FlowLeafSet {
FlowLeafSet {
- set: HashSet::new(),
+ set: ConcurrentHashMap::with_locks_and_buckets(64, 256),
}
}
/// Inserts a newly-created flow into the leaf set.
- fn insert(&mut self, flow: &~Flow) {
- self.set.insert(parallel::owned_flow_to_unsafe_flow(flow));
+ fn insert(&self, flow: &~Flow) {
+ self.set.insert(parallel::owned_flow_to_unsafe_flow(flow), ());
}
/// Removes a flow from the leaf set. Asserts that the flow was indeed in the leaf set. (This
/// invariant is needed for memory safety, as there must always be exactly one leaf set.)
- fn remove(&mut self, flow: &~Flow) {
+ fn remove(&self, flow: &~Flow) {
if !self.contains(flow) {
fail!("attempted to remove a flow from the leaf set that wasn't in the set!")
}
@@ -830,16 +829,16 @@ impl FlowLeafSet {
self.set.remove(&flow);
}
- pub fn contains(&mut self, flow: &~Flow) -> bool {
+ pub fn contains(&self, flow: &~Flow) -> bool {
let flow = parallel::owned_flow_to_unsafe_flow(flow);
- self.set.contains(&flow)
+ self.set.contains_key(&flow)
}
- pub fn clear(&mut self) {
+ pub fn clear(&self) {
self.set.clear()
}
- pub fn iter<'a>(&'a self) -> HashSetIterator<'a,UnsafeFlow> {
+ pub fn iter<'a>(&'a self) -> ConcurrentHashMapIterator<'a,UnsafeFlow,()> {
self.set.iter()
}
}