reduce node.unique_id size

fix sizeof unittest
update Cargo.lock
This commit is contained in:
Aleksandr Likhanov 2015-11-18 22:27:08 +05:00
parent 2be0cb7827
commit 4bf21ab15e
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),
}
}