-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
performance optimisation: avoid map regrow calls #875
Conversation
runtime/context.go
Outdated
@@ -119,9 +119,10 @@ func WithEndpointRequestHeadersField(ctx context.Context, requestHeaders map[str | |||
|
|||
// GetEndpointRequestHeadersFromCtx returns the endpoint request headers, if it exists on context | |||
func GetEndpointRequestHeadersFromCtx(ctx context.Context) map[string]string { | |||
requestHeaders := make(map[string]string) | |||
var requestHeaders map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have a empty map. Currently it's null. If context doesn't have headers, then nil map will be returned and there are callers which directly add new keys to map.
Ex here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch..
runtime/context.go
Outdated
@@ -205,9 +206,10 @@ func WithScopeTags(ctx context.Context, newFields map[string]string) context.Con | |||
|
|||
// GetScopeTagsFromCtx returns the tag info extracted from context. | |||
func GetScopeTagsFromCtx(ctx context.Context) map[string]string { | |||
tags := make(map[string]string) | |||
var tags map[string]string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above
No description provided.