aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-10-28 11:24:41 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-10-28 11:34:06 -0700
commita94e13f8886211b2ead8d52b3cfe43cd0c8ff998 (patch)
treebb1fe4c2d2f530373e4ea1abde42be67e4376d5d /components
parent8ab354ac085d8d70d7ccf992b5262e1969e3949a (diff)
downloadservo-a94e13f8886211b2ead8d52b3cfe43cd0c8ff998.tar.gz
servo-a94e13f8886211b2ead8d52b3cfe43cd0c8ff998.zip
script: Use an FNV hash to hash event listeners.
The security properties of SipHash are irrelevant for event listeners and the creation of the random number generator was showing up high in the profiles.
Diffstat (limited to 'components')
-rw-r--r--components/script/dom/bindings/trace.rs6
-rw-r--r--components/script/dom/eventtarget.rs5
-rw-r--r--components/script/lib.rs2
3 files changed, 8 insertions, 5 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 930fd59edbe..c4f59491c57 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -39,7 +39,7 @@ use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
use net::image_cache_task::ImageCacheTask;
use script_traits::ScriptControlChan;
use std::collections::hashmap::HashMap;
-use collections::hash::Hash;
+use collections::hash::{Hash, Hasher};
use style::PropertyDeclarationBlock;
use std::comm::{Receiver, Sender};
use string_cache::{Atom, Namespace};
@@ -170,7 +170,9 @@ impl<T: JSTraceable> JSTraceable for Option<T> {
}
}
-impl<K: Eq+Hash+JSTraceable, V: JSTraceable> JSTraceable for HashMap<K, V> {
+impl<K,V,S,H> JSTraceable for HashMap<K, V, H> where K: Eq + Hash<S> + JSTraceable,
+ V: JSTraceable,
+ H: Hasher<S> {
#[inline]
fn trace(&self, trc: *mut JSTracer) {
for e in self.iter() {
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 233047691ea..0ced9c9c41e 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -18,6 +18,7 @@ use dom::xmlhttprequest::XMLHttpRequestId;
use dom::virtualmethods::VirtualMethods;
use js::jsapi::{JS_CompileUCFunction, JS_GetFunctionObject, JS_CloneFunctionObject};
use js::jsapi::{JSContext, JSObject};
+use servo_util::fnv::FnvHasher;
use servo_util::str::DOMString;
use libc::{c_char, size_t};
use std::ptr;
@@ -69,7 +70,7 @@ pub struct EventListenerEntry {
pub struct EventTarget {
type_id: EventTargetTypeId,
reflector_: Reflector,
- handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>>>,
+ handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>, FnvHasher>>,
}
impl EventTarget {
@@ -77,7 +78,7 @@ impl EventTarget {
EventTarget {
type_id: type_id,
reflector_: Reflector::new(),
- handlers: DOMRefCell::new(HashMap::new()),
+ handlers: DOMRefCell::new(HashMap::with_hasher(FnvHasher)),
}
}
diff --git a/components/script/lib.rs b/components/script/lib.rs
index e03801f5217..02a96942927 100644
--- a/components/script/lib.rs
+++ b/components/script/lib.rs
@@ -5,7 +5,7 @@
#![comment = "The Servo Parallel Browser Project"]
#![license = "MPL"]
-#![feature(globs, macro_rules, struct_variant, phase, unsafe_destructor)]
+#![feature(default_type_params, globs, macro_rules, struct_variant, phase, unsafe_destructor)]
#![deny(unused_imports, unused_variable)]
#![allow(non_snake_case)]