mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
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:
parent
996c0a60b8
commit
4accaf50b2
25 changed files with 156 additions and 135 deletions
|
@ -12,6 +12,7 @@ use dom::bindings::inheritance::Castable;
|
|||
use dom::bindings::js::Root;
|
||||
use dom::bindings::reflector::reflect_dom_object;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use string_cache::Atom;
|
||||
use util::str::DOMString;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -36,7 +37,7 @@ impl WebGLContextEvent {
|
|||
}
|
||||
|
||||
pub fn new(global: GlobalRef,
|
||||
type_: DOMString,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable,
|
||||
status_message: DOMString) -> Root<WebGLContextEvent> {
|
||||
|
@ -47,7 +48,7 @@ impl WebGLContextEvent {
|
|||
|
||||
{
|
||||
let parent = event.upcast::<Event>();
|
||||
parent.InitEvent(type_, bubbles == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable);
|
||||
parent.init_event(type_, bubbles == EventBubbles::Bubbles, cancelable == EventCancelable::Cancelable);
|
||||
}
|
||||
|
||||
event
|
||||
|
@ -73,7 +74,7 @@ impl WebGLContextEvent {
|
|||
EventCancelable::NotCancelable
|
||||
};
|
||||
|
||||
Ok(WebGLContextEvent::new(global, type_,
|
||||
Ok(WebGLContextEvent::new(global, Atom::from(&*type_),
|
||||
bubbles,
|
||||
cancelable,
|
||||
status_message))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue