Pass around event types as Atoms instead of Strings

`Event` internally stores the `type` as an `Atom`, and we're `String`s
everywhere, which can cause unnecessary allocations to occur since
they'll end up as `Atom`s anyways.
This commit is contained in:
Corey Farwell 2015-12-10 22:06:05 -05:00
parent 996c0a60b8
commit 4accaf50b2
25 changed files with 156 additions and 135 deletions

View file

@ -15,6 +15,7 @@ use dom::event::{Event, EventBubbles, EventCancelable};
use dom::window::Window;
use std::cell::Cell;
use std::default::Default;
use string_cache::Atom;
use util::str::DOMString;
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#interface-UIEvent
@ -91,7 +92,7 @@ impl UIEventMethods for UIEvent {
return;
}
event.InitEvent(type_, can_bubble, cancelable);
event.init_event(Atom::from(&*type_), can_bubble, cancelable);
self.view.set(view);
self.detail.set(detail);
}