@@ -272,10 +272,9 @@ impl ComparableValue {
272272}
273273
274274// Used on file output arguments.
275- // Based on path inode or file_index check if the file already has been specified.
276275// If yes, use the same file pointer.
277276struct FileMemoizer {
278- mem : HashMap < u64 , Arc < File > > ,
277+ mem : HashMap < FileInformation , Arc < File > > ,
279278}
280279impl FileMemoizer {
281280 fn new ( ) -> Self {
@@ -284,30 +283,22 @@ impl FileMemoizer {
284283 }
285284 }
286285 fn get_or_create_file ( & mut self , path : & str ) -> Result < Arc < File > , Box < dyn Error > > {
287- let path = Path :: new ( path) ;
288- let file_id = self . get_file_id ( path) ;
289- if file_id. is_err ( ) {
290- let file = Arc :: new ( File :: create ( path) ?) ;
291- self . mem . insert ( self . get_file_id ( path) ?, file. clone ( ) ) ;
292- return Ok ( file) ;
286+ let mut file_info = FileInformation :: from_path ( path, true ) ;
287+ match file_info {
288+ Ok ( info) => {
289+ let file = self
290+ . mem
291+ . entry ( info)
292+ . or_insert ( Arc :: new ( File :: create ( path) ?) ) ;
293+ Ok ( file. clone ( ) )
294+ }
295+ Err ( _) => {
296+ let file = Arc :: new ( File :: create ( path) ?) ;
297+ file_info = FileInformation :: from_path ( path, true ) ;
298+ self . mem . insert ( file_info?, file. clone ( ) ) ;
299+ Ok ( file)
300+ }
293301 }
294-
295- let file = self
296- . mem
297- . entry ( file_id. unwrap ( ) )
298- . or_insert ( Arc :: new ( File :: create ( path) ?) ) ;
299- Ok ( file. clone ( ) )
300- }
301-
302- fn get_file_id ( & self , path : & Path ) -> Result < u64 , Box < dyn Error > > {
303- let file_info = FileInformation :: from_path ( path, true ) ?;
304- #[ cfg( windows) ]
305- let file_inode = file_info. file_index ( ) ;
306-
307- #[ cfg( unix) ]
308- let file_inode = file_info. inode ( ) ;
309-
310- Ok ( file_inode)
311302 }
312303}
313304
0 commit comments