Skip to content

Commit 259b71c

Browse files
committed
libct/utils: stripRoot: rm useless HasPrefix
Using strings.HasPrefix with strings.TrimPrefix results in doing the same thing (checking if prefix exists) twice. In this case, using strings.TrimPrefix right away is sufficient. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent ecf7430 commit 259b71c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libcontainer/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func stripRoot(root, path string) string {
7777
path = "/"
7878
case root == "/":
7979
// do nothing
80-
case strings.HasPrefix(path, root+"/"):
80+
default:
8181
path = strings.TrimPrefix(path, root+"/")
8282
}
8383
return CleanPath("/" + path)

0 commit comments

Comments
 (0)