Skip to content

Commit

Permalink
use const for prefix string
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeGoldsmith committed Nov 28, 2023
1 parent d18742b commit 051636a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions beeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ func readResponses(responses chan transmission.Response) {
// This uses a cache to avoid prefixing the same field name over and over again to save allocations.
// The cache will be reset if it grows too large to avoid unbounded memory growth.
func getPrefixedFieldName(key string) string {
const prefix = "app."

// return if the key already has the prefix
if strings.HasPrefix(key, "app.") {
if strings.HasPrefix(key, prefix) {
return key
}

Expand Down Expand Up @@ -396,7 +398,7 @@ func getPrefixedFieldName(key string) string {
}

// add the prefixed key to the cache and return it
prefixedKey := "app." + key
prefixedKey := prefix + key
cachedFieldNames[key] = prefixedKey
return prefixedKey
}

0 comments on commit 051636a

Please sign in to comment.