-
Notifications
You must be signed in to change notification settings - Fork 1
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
*: pull in fixes #65
*: pull in fixes #65
Conversation
The matchers slice is now sorted in each call but that introduces a data race because the slice is shared between all calls. Do the sorting once on the outermost function. Signed-off-by: Giedrius Statkevičius <[email protected]>
Signed-off-by: Ben Ye <[email protected]>
sort.Slice(matchers, func(i, j int) bool { | ||
if matchers[i].Type == matchers[j].Type { | ||
if matchers[i].Name == matchers[j].Name { | ||
return matchers[i].Value < matchers[j].Value | ||
} | ||
return matchers[i].Name < matchers[j].Name | ||
} | ||
return matchers[i].Type < matchers[j].Type | ||
}) | ||
|
||
return matchers |
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.
nit: could reduce nesting by:
sort.Slice(matchers, func(i, j int) bool {
if matchers[i].Type != matchers[j].Type {
return matchers[i].Type < matchers[j].Type
}
if matchers[i].Name == matchers[j].Name {
return matchers[i].Value < matchers[j].Value
}
return matchers[i].Name < matchers[j].Name
})
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.
In the original PR I copied/pasted the same logic thanos-io#6575 so I'd prefer to keep the same to reduce discrepancy 😄
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 could update both PR's 😏 😄
Pull in data race fixes while I work on repro tests.