slices,sort: explicitly discard results in benchmarks
The unusedresult analyzer will report failure to use the results of these pure functions. Updates #73950 Change-Id: I783cb92ad913105afd46c782bedf6234410c645d Reviewed-on: https://go-review.googlesource.com/c/go/+/677995 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
a8e99ab19c
commit
e9d3b030ed
@ -23,7 +23,7 @@ func BenchmarkBinarySearchFloats(b *testing.B) {
|
||||
needle := (floats[midpoint] + floats[midpoint+1]) / 2
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
slices.BinarySearch(floats, needle)
|
||||
_, _ = slices.BinarySearch(floats, needle)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -46,7 +46,7 @@ func BenchmarkBinarySearchFuncStruct(b *testing.B) {
|
||||
cmpFunc := func(a, b *myStruct) int { return a.n - b.n }
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
slices.BinarySearchFunc(structs, needle, cmpFunc)
|
||||
_, _ = slices.BinarySearchFunc(structs, needle, cmpFunc)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -264,19 +264,19 @@ func TestMinMaxPanics(t *testing.T) {
|
||||
intCmp := func(a, b int) int { return a - b }
|
||||
emptySlice := []int{}
|
||||
|
||||
if !panics(func() { Min(emptySlice) }) {
|
||||
if !panics(func() { _ = Min(emptySlice) }) {
|
||||
t.Errorf("Min([]): got no panic, want panic")
|
||||
}
|
||||
|
||||
if !panics(func() { Max(emptySlice) }) {
|
||||
if !panics(func() { _ = Max(emptySlice) }) {
|
||||
t.Errorf("Max([]): got no panic, want panic")
|
||||
}
|
||||
|
||||
if !panics(func() { MinFunc(emptySlice, intCmp) }) {
|
||||
if !panics(func() { _ = MinFunc(emptySlice, intCmp) }) {
|
||||
t.Errorf("MinFunc([]): got no panic, want panic")
|
||||
}
|
||||
|
||||
if !panics(func() { MaxFunc(emptySlice, intCmp) }) {
|
||||
if !panics(func() { _ = MaxFunc(emptySlice, intCmp) }) {
|
||||
t.Errorf("MaxFunc([]): got no panic, want panic")
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func BenchmarkSlicesIsSorted(b *testing.B) {
|
||||
b.StopTimer()
|
||||
ints := makeSortedInts(N)
|
||||
b.StartTimer()
|
||||
slices.IsSorted(ints)
|
||||
_ = slices.IsSorted(ints)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user