diff --git a/Cargo.toml b/Cargo.toml index 8f91409b..854027e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ selectors = "0.23.0" smallvec = "1.9.0" tendril = "0.4.3" indexmap = { version = "1.9.1", optional = true } +ahash = "0.8" [dependencies.getopts] version = "0.2.21" diff --git a/src/main.rs b/src/main.rs index 66fe2895..9d4684b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -129,5 +129,5 @@ fn main() { .any(|m| m) }; - process::exit(if matched { 0 } else { 1 }); + process::exit(i32::from(!matched)); } diff --git a/src/node.rs b/src/node.rs index 78d5f940..c0eb9ec3 100644 --- a/src/node.rs +++ b/src/node.rs @@ -1,7 +1,7 @@ //! HTML nodes. +use ahash::{HashMap, HashSet}; use std::collections::{hash_map, hash_set}; -use std::collections::{HashMap, HashSet}; use std::fmt; use std::ops::Deref; @@ -223,10 +223,10 @@ pub struct Element { pub name: QualName, /// The element ID. - pub id: Option, + pub id: Option, /// The element classes. - pub classes: HashSet, + pub classes: HashSet, /// The element attributes. pub attrs: Attributes, @@ -238,16 +238,16 @@ impl Element { let id = attrs .iter() .find(|a| a.name.local.deref() == "id") - .map(|a| LocalName::from(a.value.deref())); + .map(|a| String::from(a.value.deref())); - let classes: HashSet = attrs + let classes: HashSet = attrs .iter() .find(|a| a.name.local.deref() == "class") - .map_or(HashSet::new(), |a| { + .map_or(HashSet::default(), |a| { a.value .deref() .split_whitespace() - .map(LocalName::from) + .map(String::from) .collect() }); @@ -300,7 +300,7 @@ impl Element { #[allow(missing_debug_implementations)] #[derive(Clone)] pub struct Classes<'a> { - inner: hash_set::Iter<'a, LocalName>, + inner: hash_set::Iter<'a, String>, } impl<'a> Iterator for Classes<'a> { diff --git a/src/selector.rs b/src/selector.rs index a33c2a9c..dabc9fa7 100644 --- a/src/selector.rs +++ b/src/selector.rs @@ -67,6 +67,8 @@ impl<'i> parser::Parser<'i> for Parser { pub struct Simple; impl parser::SelectorImpl for Simple { + // see: https://github.com/servo/servo/pull/19747#issuecomment-357106065 + type ExtraMatchingData = String; type AttrValue = CssString; type Identifier = CssLocalName; type LocalName = CssLocalName; @@ -74,12 +76,9 @@ impl parser::SelectorImpl for Simple { type NamespaceUrl = Namespace; type BorrowedNamespaceUrl = Namespace; type BorrowedLocalName = CssLocalName; - type NonTSPseudoClass = NonTSPseudoClass; - type PseudoElement = PseudoElement; - // see: https://github.com/servo/servo/pull/19747#issuecomment-357106065 - type ExtraMatchingData = String; + type PseudoElement = PseudoElement; } /// Wraps [`String`] so that it can be used with [`selectors`]