44// file that was distributed with this source code.
55use super :: PathData ;
66use lscolors:: { Indicator , LsColors , Style } ;
7+ use rustc_hash:: FxHashMap ;
78use std:: borrow:: Cow ;
8- use std:: collections:: HashMap ;
99use std:: env;
1010use std:: ffi:: OsString ;
1111use std:: fs:: { self , Metadata } ;
@@ -45,7 +45,7 @@ pub(crate) struct StyleManager<'a> {
4545 pub ( crate ) initial_reset_is_done : bool ,
4646 pub ( crate ) colors : & ' a LsColors ,
4747 /// raw indicator codes as specified in LS_COLORS (if available)
48- indicator_codes : HashMap < Indicator , String > ,
48+ indicator_codes : FxHashMap < Indicator , String > ,
4949 /// whether ln=target is active
5050 ln_color_from_target : bool ,
5151}
@@ -746,8 +746,8 @@ fn is_valid_ls_colors_prefix(label: [u8; 2]) -> bool {
746746 )
747747}
748748
749- fn parse_indicator_codes ( ) -> ( HashMap < Indicator , String > , bool ) {
750- let mut indicator_codes = HashMap :: new ( ) ;
749+ fn parse_indicator_codes ( ) -> ( FxHashMap < Indicator , String > , bool ) {
750+ let mut indicator_codes = FxHashMap :: default ( ) ;
751751 let mut ln_color_from_target = false ;
752752
753753 // LS_COLORS validity is checked before enabling color output, so parse
@@ -813,7 +813,7 @@ mod tests {
813813
814814 fn style_manager (
815815 colors : & LsColors ,
816- indicator_codes : HashMap < Indicator , String > ,
816+ indicator_codes : FxHashMap < Indicator , String > ,
817817 ) -> StyleManager < ' _ > {
818818 StyleManager {
819819 current_style : None ,
@@ -827,21 +827,21 @@ mod tests {
827827 #[ test]
828828 fn has_indicator_style_ignores_fallback_styles ( ) {
829829 let colors = LsColors :: from_string ( "ex=00:fi=32" ) ;
830- let manager = style_manager ( & colors, HashMap :: new ( ) ) ;
830+ let manager = style_manager ( & colors, FxHashMap :: default ( ) ) ;
831831 assert ! ( !manager. has_indicator_style( Indicator :: ExecutableFile ) ) ;
832832 }
833833
834834 #[ test]
835835 fn has_indicator_style_detects_explicit_styles ( ) {
836836 let colors = LsColors :: from_string ( "ex=01;32" ) ;
837- let manager = style_manager ( & colors, HashMap :: new ( ) ) ;
837+ let manager = style_manager ( & colors, FxHashMap :: default ( ) ) ;
838838 assert ! ( manager. has_indicator_style( Indicator :: ExecutableFile ) ) ;
839839 }
840840
841841 #[ test]
842842 fn has_indicator_style_detects_raw_codes ( ) {
843843 let colors = LsColors :: empty ( ) ;
844- let mut indicator_codes = HashMap :: new ( ) ;
844+ let mut indicator_codes = FxHashMap :: default ( ) ;
845845 indicator_codes. insert ( Indicator :: Directory , "01;34" . to_string ( ) ) ;
846846 let manager = style_manager ( & colors, indicator_codes) ;
847847 assert ! ( manager. has_indicator_style( Indicator :: Directory ) ) ;
0 commit comments