Commit 9313ba19 authored by Kevin Atkinson's avatar Kevin Atkinson

Avoid creating unnecessary strings when key is already in correct format

parent 971a83c4
......@@ -65,7 +65,14 @@ func KeyWithNamespaces(ns []string) Key {
// Clean up a Key, using path.Clean.
func (k *Key) Clean() {
k.string = path.Clean("/" + k.string)
switch {
case len(k.string) == 0:
k.string = "/"
case k.string[0] == '/':
k.string = path.Clean(k.string)
default:
k.string = path.Clean("/" + k.string)
}
}
// Strings is the string value of Key
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment