mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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:
parent
6d381959db
commit
300004f3e9
75 changed files with 80 additions and 316 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue