@@ -272,10 +272,9 @@ impl ComparableValue {
272
272
}
273
273
274
274
// Used on file output arguments.
275
- // Based on path inode or file_index check if the file already has been specified.
276
275
// If yes, use the same file pointer.
277
276
struct FileMemoizer {
278
- mem : HashMap < u64 , Arc < File > > ,
277
+ mem : HashMap < FileInformation , Arc < File > > ,
279
278
}
280
279
impl FileMemoizer {
281
280
fn new ( ) -> Self {
@@ -284,30 +283,22 @@ impl FileMemoizer {
284
283
}
285
284
}
286
285
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
+ }
293
301
}
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)
311
302
}
312
303
}
313
304
0 commit comments