@@ -32,12 +32,11 @@ use kuchiki::{
3232pub mod error;
3333mod parser;
3434
35- use ahash :: AHashMap ;
35+ use indexmap :: IndexMap ;
3636pub use error:: InlineError ;
3737use smallvec:: { smallvec, SmallVec } ;
3838use std:: {
3939 borrow:: Cow ,
40- collections:: hash_map:: Entry ,
4140 fs,
4241 io:: { ErrorKind , Write } ,
4342} ;
@@ -239,7 +238,7 @@ impl<'a> CSSInliner<'a> {
239238 // and then reused, which allows O(1) access to find them.
240239 // Internally, their raw pointers are used to implement `Eq`, which seems like the only
241240 // reasonable approach to compare them (performance-wise).
242- let mut styles = AHashMap :: with_capacity ( 128 ) ;
241+ let mut styles = IndexMap :: with_capacity ( 128 ) ;
243242 let mut style_tags: SmallVec < [ NodeDataRef < ElementData > ; 4 ] > = smallvec ! [ ] ;
244243 if self . options . inline_style_tags {
245244 for style_tag in document
@@ -358,7 +357,7 @@ type NodeId = *const Node;
358357fn process_css (
359358 document : & NodeRef ,
360359 css : & str ,
361- styles : & mut AHashMap < NodeId , AHashMap < String , ( Specificity , String ) > > ,
360+ styles : & mut IndexMap < NodeId , IndexMap < String , ( Specificity , String ) > > ,
362361) {
363362 let mut parse_input = cssparser:: ParserInput :: new ( css) ;
364363 let mut parser = cssparser:: Parser :: new ( & mut parse_input) ;
@@ -374,15 +373,15 @@ fn process_css(
374373 for matching_element in matching_elements {
375374 let element_styles = styles
376375 . entry ( & * * matching_element. as_node ( ) )
377- . or_insert_with ( || AHashMap :: with_capacity ( 8 ) ) ;
376+ . or_insert_with ( || IndexMap :: with_capacity ( 8 ) ) ;
378377 for ( name, value) in & declarations {
379378 match element_styles. entry ( name. to_string ( ) ) {
380- Entry :: Occupied ( mut entry) => {
379+ indexmap :: map :: Entry :: Occupied ( mut entry) => {
381380 if entry. get ( ) . 0 <= specificity {
382381 entry. insert ( ( specificity, ( * value) . to_string ( ) ) ) ;
383382 }
384383 }
385- Entry :: Vacant ( entry) => {
384+ indexmap :: map :: Entry :: Vacant ( entry) => {
386385 entry. insert ( ( specificity, ( * value) . to_string ( ) ) ) ;
387386 }
388387 }
@@ -432,7 +431,7 @@ pub fn inline_to<W: Write>(html: &str, target: &mut W) -> Result<()> {
432431
433432fn merge_styles (
434433 existing_style : & str ,
435- new_styles : & AHashMap < String , ( Specificity , String ) > ,
434+ new_styles : & IndexMap < String , ( Specificity , String ) > ,
436435) -> Result < String > {
437436 // Parse existing declarations in the "style" attribute
438437 let mut input = cssparser:: ParserInput :: new ( existing_style) ;
0 commit comments