77
88//! Set of functions to manage xattr on files and dirs
99use itertools:: Itertools ;
10- use std :: collections :: HashMap ;
10+ use rustc_hash :: FxHashMap ;
1111use std:: ffi:: { OsStr , OsString } ;
1212#[ cfg( unix) ]
1313use std:: os:: unix:: ffi:: OsStrExt ;
@@ -54,8 +54,8 @@ pub fn copy_xattrs_skip_selinux<P: AsRef<Path>>(source: P, dest: P) -> std::io::
5454/// # Returns
5555///
5656/// A result containing a HashMap of attributes names and values, or an error.
57- pub fn retrieve_xattrs < P : AsRef < Path > > ( source : P ) -> std:: io:: Result < HashMap < OsString , Vec < u8 > > > {
58- let mut attrs = HashMap :: new ( ) ;
57+ pub fn retrieve_xattrs < P : AsRef < Path > > ( source : P ) -> std:: io:: Result < FxHashMap < OsString , Vec < u8 > > > {
58+ let mut attrs = FxHashMap :: default ( ) ;
5959 for attr_name in xattr:: list ( & source) ? {
6060 if let Some ( value) = xattr:: get ( & source, & attr_name) ? {
6161 attrs. insert ( attr_name, value) ;
@@ -76,7 +76,7 @@ pub fn retrieve_xattrs<P: AsRef<Path>>(source: P) -> std::io::Result<HashMap<OsS
7676/// A result indicating success or failure.
7777pub fn apply_xattrs < P : AsRef < Path > > (
7878 dest : P ,
79- xattrs : HashMap < OsString , Vec < u8 > > ,
79+ xattrs : FxHashMap < OsString , Vec < u8 > > ,
8080) -> std:: io:: Result < ( ) > {
8181 for ( attr, value) in xattrs {
8282 xattr:: set ( & dest, & attr, & value) ?;
@@ -207,7 +207,7 @@ mod tests {
207207
208208 File :: create ( & file_path) . unwrap ( ) ;
209209
210- let mut test_xattrs = HashMap :: new ( ) ;
210+ let mut test_xattrs = FxHashMap :: default ( ) ;
211211 let test_attr = "user.test_attr" ;
212212 let test_value = b"test value" ;
213213 test_xattrs. insert ( OsString :: from ( test_attr) , test_value. to_vec ( ) ) ;
0 commit comments