1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-10-30 23:47:59 +02:00

perf(metadata): simplify Metadata.Add by avoiding redundant strings.ToLower call (#3671)

This commit is contained in:
Name
2025-05-27 23:29:16 +08:00
committed by GitHub
parent c82f795722
commit d6f5f00cf5

View File

@@ -26,11 +26,12 @@ func New(mds ...map[string][]string) Metadata {
// Add adds the key, value pair to the header.
func (m Metadata) Add(key, value string) {
if len(key) == 0 {
if key == "" {
return
}
m[strings.ToLower(key)] = append(m[strings.ToLower(key)], value)
lowerKey := strings.ToLower(key)
m[lowerKey] = append(m[lowerKey], value)
}
// Get returns the value associated with the passed key.