@@ -106,19 +106,19 @@ impl Default for FileSystemOs {
106106 }
107107}
108108
109- // fn read_to_string(path: &Path) -> io::Result<String> {
110- // // `simdutf8` is faster than `std::str::from_utf8` which `fs::read_to_string` uses internally
111- // let bytes = std::fs::read(path)?;
112- // if simdutf8::basic::from_utf8(&bytes).is_err() {
113- // // Same error as `fs::read_to_string` produces (`io::Error::INVALID_UTF8`)
114- // return Err(io::Error::new(
115- // io::ErrorKind::InvalidData,
116- // "stream did not contain valid UTF-8",
117- // ));
118- // }
119- // // SAFETY: `simdutf8` has ensured it's a valid UTF-8 string
120- // Ok(unsafe { String::from_utf8_unchecked(bytes) })
121- // }
109+ fn read_to_string ( path : & Path ) -> io:: Result < String > {
110+ // `simdutf8` is faster than `std::str::from_utf8` which `fs::read_to_string` uses internally
111+ let bytes = std:: fs:: read ( path) ?;
112+ if simdutf8:: basic:: from_utf8 ( & bytes) . is_err ( ) {
113+ // Same error as `fs::read_to_string` produces (`io::Error::INVALID_UTF8`)
114+ return Err ( io:: Error :: new (
115+ io:: ErrorKind :: InvalidData ,
116+ "stream did not contain valid UTF-8" ,
117+ ) ) ;
118+ }
119+ // SAFETY: `simdutf8` has ensured it's a valid UTF-8 string
120+ Ok ( unsafe { String :: from_utf8_unchecked ( bytes) } )
121+ }
122122
123123impl FileSystem for FileSystemOs {
124124 fn read_to_string < ' a > ( & ' a self , path : & ' a Path ) -> BoxFuture < ' a , io:: Result < String > > {
@@ -129,11 +129,11 @@ impl FileSystem for FileSystemOs {
129129 VPath :: Zip ( info) => {
130130 self . pnp_lru. read_to_string( info. physical_base_path( ) , info. zip_path)
131131 }
132- VPath :: Virtual ( info) => tokio :: fs :: read_to_string( & info. physical_base_path( ) ) . await ,
133- VPath :: Native ( path) => tokio :: fs :: read_to_string( & path) . await ,
132+ VPath :: Virtual ( info) => read_to_string( & info. physical_base_path( ) ) ,
133+ VPath :: Native ( path) => read_to_string( & path) ,
134134 }
135135 } else {
136- tokio :: fs :: read_to_string( path) . await
136+ read_to_string( path)
137137 }
138138 }
139139 } ;
@@ -150,20 +150,20 @@ impl FileSystem for FileSystemOs {
150150 . file_type( info. physical_base_path( ) , info. zip_path)
151151 . map( FileMetadata :: from) ,
152152 VPath :: Virtual ( info) => {
153- tokio :: fs:: metadata( info. physical_base_path( ) ) . await . map( FileMetadata :: from)
153+ fs:: metadata( info. physical_base_path( ) ) . map( FileMetadata :: from)
154154 }
155- VPath :: Native ( path) => tokio :: fs:: metadata( path) . await . map( FileMetadata :: from) ,
155+ VPath :: Native ( path) => fs:: metadata( path) . map( FileMetadata :: from) ,
156156 }
157157 } else {
158- tokio :: fs:: metadata( path) . await . map( FileMetadata :: from)
158+ fs:: metadata( path) . map( FileMetadata :: from)
159159 }
160160 }
161161 } ;
162162 Box :: pin ( fut)
163163 }
164164
165165 fn symlink_metadata < ' a > ( & ' a self , path : & ' a Path ) -> BoxFuture < ' a , io:: Result < FileMetadata > > {
166- let fut = async move { tokio :: fs:: symlink_metadata ( path) . await . map ( FileMetadata :: from) } ;
166+ let fut = async move { fs:: symlink_metadata ( path) . map ( FileMetadata :: from) } ;
167167 Box :: pin ( fut)
168168 }
169169
@@ -184,7 +184,7 @@ impl FileSystem for FileSystemOs {
184184 use std:: path:: Component ;
185185 let mut path_buf = path. to_path_buf( ) ;
186186 loop {
187- let link = tokio :: fs:: read_link( & path_buf) . await ?;
187+ let link = fs:: read_link( & path_buf) ?;
188188 path_buf. pop( ) ;
189189 for component in link. components( ) {
190190 match component {
@@ -208,7 +208,7 @@ impl FileSystem for FileSystemOs {
208208 Component :: CurDir | Component :: Prefix ( _) => { }
209209 }
210210 }
211- if !tokio :: fs:: symlink_metadata( & path_buf) . await ?. is_symlink( ) {
211+ if !fs:: symlink_metadata( & path_buf) ?. is_symlink( ) {
212212 break ;
213213 }
214214 }
0 commit comments