You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-08-10 22:31:50 +02:00
attribute: preallocate map in NewAllowKeysFilter and NewDenyKeysFilter (#6455)
preallocate map in `NewAllowKeysFilter` and `NewDenyKeysFilter` to avoid necessary allocations
This commit is contained in:
@@ -19,7 +19,7 @@ func NewAllowKeysFilter(keys ...Key) Filter {
|
||||
return func(kv KeyValue) bool { return false }
|
||||
}
|
||||
|
||||
allowed := make(map[Key]struct{})
|
||||
allowed := make(map[Key]struct{}, len(keys))
|
||||
for _, k := range keys {
|
||||
allowed[k] = struct{}{}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func NewDenyKeysFilter(keys ...Key) Filter {
|
||||
return func(kv KeyValue) bool { return true }
|
||||
}
|
||||
|
||||
forbid := make(map[Key]struct{})
|
||||
forbid := make(map[Key]struct{}, len(keys))
|
||||
for _, k := range keys {
|
||||
forbid[k] = struct{}{}
|
||||
}
|
||||
|
Reference in New Issue
Block a user