Auto merge of #8589 - vegayours:8360_reduce_node_unique_id_size, r=eefriedman

Reduce node.unique_id size

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8589)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-20 01:44:19 +05:30
commit e5c9b48598
9 changed files with 35 additions and 27 deletions

View file

@ -88,6 +88,7 @@ use style::restyle_hints::ElementSnapshot;
use style::values::specified::Length;
use url::Url;
use util::str::{DOMString, LengthOrPercentageOrAuto};
use uuid::Uuid;
/// A trait to allow tracing (only) DOM objects.
@ -252,7 +253,7 @@ impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
}
no_jsmanaged_fields!(bool, f32, f64, String, Url, AtomicBool);
no_jsmanaged_fields!(bool, f32, f64, String, Url, AtomicBool, Uuid);
no_jsmanaged_fields!(usize, u8, u16, u32, u64);
no_jsmanaged_fields!(isize, i8, i16, i32, i64);
no_jsmanaged_fields!(Sender<T>);

View file

@ -67,7 +67,7 @@ use string_cache::{Atom, Namespace, QualName};
use style::properties::ComputedValues;
use util::str::DOMString;
use util::task_state;
use uuid;
use uuid::Uuid;
//
// The basic Node structure
@ -115,7 +115,7 @@ pub struct Node {
/// node is finalized.
layout_data: LayoutDataRef,
unique_id: DOMRefCell<String>,
unique_id: DOMRefCell<Option<Box<Uuid>>>,
}
impl PartialEq for Node {
@ -793,11 +793,11 @@ impl Node {
}
pub fn get_unique_id(&self) -> String {
if self.unique_id.borrow().is_empty() {
if self.unique_id.borrow().is_none() {
let mut unique_id = self.unique_id.borrow_mut();
*unique_id = uuid::Uuid::new_v4().to_simple_string();
*unique_id = Some(Box::new(Uuid::new_v4()));
}
self.unique_id.borrow().clone()
self.unique_id.borrow().as_ref().unwrap().to_simple_string()
}
pub fn summarize(&self) -> NodeInfo {
@ -1310,7 +1310,7 @@ impl Node {
layout_data: LayoutDataRef::new(),
unique_id: DOMRefCell::new(String::new()),
unique_id: DOMRefCell::new(None),
}
}