Skip to content

Commit

Permalink
libct/utils: stripRoot: rm useless HasPrefix
Browse files Browse the repository at this point in the history
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 <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Jan 10, 2025
1 parent 861d9ba commit fffc54a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libcontainer/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func stripRoot(root, path string) string {
path = "/"
case root == "/":
// do nothing
case strings.HasPrefix(path, root+"/"):
default:
path = strings.TrimPrefix(path, root+"/")
}
return CleanPath("/" + path)
Expand Down

0 comments on commit fffc54a

Please sign in to comment.