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),
}
}

View file

@ -1192,7 +1192,7 @@ dependencies = [
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1542,7 +1542,7 @@ dependencies = [
"unicase 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"websocket 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)",
"xml5ever 0.1.0 (git+https://github.com/Ygg01/xml5ever)",
]
@ -1925,6 +1925,7 @@ dependencies = [
"smallvec 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1940,7 +1941,7 @@ dependencies = [
[[package]]
name = "uuid"
version = "0.1.17"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1994,7 +1995,7 @@ dependencies = [
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2011,7 +2012,7 @@ dependencies = [
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
"uuid 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"webdriver 0.3.1 (git+https://github.com/jgraham/webdriver-rust.git)",
]

View file

@ -56,3 +56,4 @@ string_cache = "0.1"
lazy_static = "0.1"
getopts = "0.2.11"
hyper = "0.6"
uuid = "0.1.17"

View file

@ -49,6 +49,7 @@ extern crate serde;
extern crate smallvec;
extern crate string_cache;
extern crate url;
extern crate uuid;
use std::sync::Arc;

View file

@ -39,6 +39,7 @@ use str::{DOMString, LengthOrPercentageOrAuto};
use string_cache::atom::Atom;
use string_cache::namespace::{QualName, Namespace};
use url;
use uuid::Uuid;
extern {
// Get the size of a heap block.
@ -425,3 +426,4 @@ known_heap_size!(0, JSVal, PagePx, ViewportPx, DevicePixel, QuirksMode, OsRng, R
known_heap_size!(0, TokenSerializationType, LengthOrPercentageOrAuto);
known_heap_size!(0, ElementState, Combinator, PseudoElement, str);
known_heap_size!(0, Uuid);