mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 22:05:59 +00:00
mount-utils: isMountPointMatch: simplify and speedup
Here's before/after comparison. [kir@kir-rhat mount-utils]$ benchstat before after name old time/op new time/op delta IsMountPointMatch-4 707ns ± 1% 40ns ± 1% -94.39% (p=0.008 n=5+5) name old alloc/op new alloc/op delta IsMountPointMatch-4 264B ± 0% 0B -100.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta IsMountPointMatch-4 11.0 ± 0% 0.0 -100.00% (p=0.008 n=5+5) Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
404e844468
commit
8c79a91133
@ -173,8 +173,7 @@ func splitMountOptions(s string) []string {
|
||||
// isMountPointMatch returns true if the path in mp is the same as dir.
|
||||
// Handles case where mountpoint dir has been renamed due to stale NFS mount.
|
||||
func isMountPointMatch(mp MountPoint, dir string) bool {
|
||||
deletedDir := fmt.Sprintf("%s\\040(deleted)", dir)
|
||||
return ((mp.Path == dir) || (mp.Path == deletedDir))
|
||||
return strings.TrimSuffix(mp.Path, "\\040(deleted)") == dir
|
||||
}
|
||||
|
||||
// PathExists returns true if the specified path exists.
|
||||
|
Loading…
Reference in New Issue
Block a user