Skip to content

Commit

Permalink
reduce usage of fmt.Sprintf in cachekey string (#6214)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Ye <[email protected]>
  • Loading branch information
yeya24 authored Mar 15, 2023
1 parent 75652e6 commit 2ab0ec2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/store/cache/cachekey/cachekey.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package cachekey

import (
"fmt"
"strconv"
"strings"

Expand Down Expand Up @@ -38,10 +37,10 @@ type BucketCacheKey struct {
// String returns the string representation of BucketCacheKey.
func (ck BucketCacheKey) String() string {
if ck.Start == 0 && ck.End == 0 {
return fmt.Sprintf("%s:%s", ck.Verb, ck.Name)
return string(ck.Verb) + ":" + ck.Name
}

return fmt.Sprintf("%s:%s:%d:%d", ck.Verb, ck.Name, ck.Start, ck.End)
return strings.Join([]string{string(ck.Verb), ck.Name, strconv.FormatInt(ck.Start, 10), strconv.FormatInt(ck.End, 10)}, ":")
}

// IsValidVerb checks if the VerbType matches the predefined verbs.
Expand Down

0 comments on commit 2ab0ec2

Please sign in to comment.