Use == instead of match for tests against a single enum value

The performance of using == should now equal that of match, so many
identity methods can be simplified to a single line.

Fixes #1596.
This commit is contained in:
Martin Robinson 2014-05-08 13:27:59 -07:00
parent 6d381959db
commit 300004f3e9
75 changed files with 80 additions and 316 deletions

View file

@ -497,36 +497,22 @@ impl<'a> NodeHelpers for JSRef<'a, Node> {
#[inline]
fn is_document(&self) -> bool {
match self.type_id() {
DocumentNodeTypeId => true,
_ => false
}
self.type_id() == DocumentNodeTypeId
}
#[inline]
fn is_anchor_element(&self) -> bool {
match self.type_id() {
ElementNodeTypeId(HTMLAnchorElementTypeId) => true,
_ => false
}
self.type_id() == ElementNodeTypeId(HTMLAnchorElementTypeId)
}
#[inline]
fn is_doctype(&self) -> bool {
match self.type_id {
DoctypeNodeTypeId => true,
_ => false
}
self.type_id == DoctypeNodeTypeId
}
#[inline]
fn is_text(&self) -> bool {
// FIXME(pcwalton): Temporary workaround for the lack of inlining of autogenerated `Eq`
// implementations in Rust.
match self.type_id() {
TextNodeTypeId => true,
_ => false
}
self.type_id() == TextNodeTypeId
}
fn get_hover_state(&self) -> bool {