File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -42,9 +42,20 @@ impl<Fs: FileSystem> Cache<Fs> {
42
42
}
43
43
44
44
pub fn value ( & self , path : & Path ) -> CachedPath {
45
+ // `Path::hash` is slow: https://doc.rust-lang.org/std/path/struct.Path.html#impl-Hash-for-Path
46
+ // `path.as_os_str()` hash is not stable because we may joined a path like `foo/bar` and `foo\\bar` on windows.
45
47
let hash = {
46
48
let mut hasher = FxHasher :: default ( ) ;
47
- path. as_os_str ( ) . hash ( & mut hasher) ;
49
+ for b in path
50
+ . as_os_str ( )
51
+ . as_encoded_bytes ( )
52
+ . iter ( )
53
+ . rev ( )
54
+ . filter ( |& & b| b != b'/' && b != b'\\' )
55
+ . take ( 10 )
56
+ {
57
+ b. hash ( & mut hasher) ;
58
+ }
48
59
hasher. finish ( )
49
60
} ;
50
61
if let Some ( cache_entry) = self . paths . get ( ( hash, path) . borrow ( ) as & dyn CacheKey ) {
You can’t perform that action at this time.
0 commit comments