Fix with go fix

This commit is contained in:
sergystepanov 2025-12-22 15:08:50 +03:00
parent 7c91d200e4
commit c800dd4bf9
11 changed files with 23 additions and 25 deletions

View file

@ -82,7 +82,7 @@ func testUnReserveConcurrent(t *testing.T) {
atomic.StoreInt32((*int32)(&s), int32(workers))
wg.Add(workers)
for i := 0; i < workers; i++ {
for range workers {
go func() {
defer wg.Done()
s.UnReserve()
@ -126,7 +126,7 @@ func testTryReserveConcurrent(t *testing.T) {
var wg sync.WaitGroup
wg.Add(workers)
for i := 0; i < workers; i++ {
for range workers {
go func() {
defer wg.Done()
if s.TryReserve() {

View file

@ -9,12 +9,12 @@ func ToRGBA(img image.Image, flipped bool) *image.RGBA {
bounds := img.Bounds()
sw, sh := bounds.Dx(), bounds.Dy()
dst := image.NewRGBA(image.Rect(0, 0, sw, sh))
for y := 0; y < sh; y++ {
for y := range sh {
yy := y
if flipped {
yy = sh - y
}
for x := 0; x < sw; x++ {
for x := range sw {
px := img.At(x, y)
rgba := color.RGBAModel.Convert(px).(color.RGBA)
dst.Set(x, yy, rgba)

View file

@ -23,7 +23,7 @@ func Benchmark(b *testing.B) {
return
}
data := make([]byte, int(float64(w)*float64(h)*1.5))
for i := 0; i < b.N; i++ {
for b.Loop() {
h264.Encode(data)
}
}

View file

@ -123,7 +123,7 @@ func TestYuvPredefined(t *testing.T) {
t.Fatalf("different size a: %v, o: %v", len(a), len(should))
}
for i := 0; i < len(a); i++ {
for i := range a {
if a[i] != should[i] {
t.Fatalf("diff in %vth, %v != %v \n%v\n%v", i, a[i], should[i], im, should)
}
@ -188,8 +188,8 @@ func BenchmarkYuv(b *testing.B) {
func genFrame(w, h int, seed float32) RawFrame {
img := image.NewRGBA(image.Rectangle{Max: image.Point{X: w, Y: h}})
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
for x := range w {
for y := range h {
col := color.RGBA{R: uint8(seed * 255), G: uint8(seed * 255), B: uint8(seed * 255), A: 0xff}
img.Set(x, y, col)
}
@ -217,9 +217,9 @@ func TestGen24bitFull(t *testing.T) {
// radius = centerY
//}
for y := 0; y < wh; y++ {
for y := range wh {
dy := float64(y - centerY)
for x := 0; x < wh; x++ {
for x := range wh {
dx := float64(x - centerX)
dist := math.Sqrt(dx*dx + dy*dy)
if dist <= float64(radius) {

View file

@ -117,7 +117,7 @@ func Benchmark(b *testing.B) {
Supported: []string{"gba", "zip", "nes"},
}, config.Emulator{}, log)
for range b.N {
for b.Loop() {
library.Scan()
_ = library.GetAll()
}

View file

@ -10,7 +10,7 @@ func Linear(dst, src []int16) {
// replicate single pair input or output
if srcPairs == 1 || dstPairs == 1 {
for i := 0; i < dstPairs; i++ {
for i := range dstPairs {
dst[i*2], dst[i*2+1] = src[0], src[1]
}
return
@ -46,7 +46,7 @@ func Nearest(dst, src []int16) {
srcPairs, dstPairs := nSrc>>1, nDst>>1
if srcPairs == 1 || dstPairs == 1 {
for i := 0; i < dstPairs; i++ {
for i := range dstPairs {
dst[i*2], dst[i*2+1] = src[0], src[1]
}
return

View file

@ -329,8 +329,7 @@ func TestStateConcurrency(t *testing.T) {
qLock.Unlock()
if lucky() && !lucky() {
ops.Add(1)
go func() {
ops.Go(func() {
qLock.Lock()
defer qLock.Unlock()
@ -344,8 +343,7 @@ func TestStateConcurrency(t *testing.T) {
if snapshot1 != snapshot2 {
t.Errorf("States are inconsistent %v != %v on tick %v\n", snapshot1, snapshot2, i+1)
}
ops.Done()
}()
})
}
}

View file

@ -13,7 +13,7 @@ func TestConcurrentInput(t *testing.T) {
events := 1000
wg.Add(2 * events)
for i := 0; i < events; i++ {
for range events {
player := rand.Intn(maxPort)
go func() { state.Input(player, []byte{0, 1}); wg.Done() }()
go func() { state.IsKeyPressed(uint(player), 100); wg.Done() }()

View file

@ -26,7 +26,7 @@ func samplesOf(v int16, n int) samples {
func ramp(pairs int) samples {
s := make(samples, pairs*2)
for i := 0; i < pairs; i++ {
for i := range pairs {
s[i*2], s[i*2+1] = int16(i), int16(i)
}
return s

View file

@ -79,7 +79,7 @@ func run(w, h int, cod encoder.VideoCodec, count int, a *image.RGBA, b *image.RG
b = genTestImage(w, h, rand.Float32())
}
for i := 0; i < count; i++ {
for i := range count {
im := a
if i%2 == 0 {
im = b
@ -98,8 +98,8 @@ func run(w, h int, cod encoder.VideoCodec, count int, a *image.RGBA, b *image.RG
func genTestImage(w, h int, seed float32) *image.RGBA {
img := image.NewRGBA(image.Rectangle{Max: image.Point{X: w, Y: h}})
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
for x := range w {
for y := range h {
i := img.PixOffset(x, y)
s := img.Pix[i : i+4 : i+4]
s[0] = uint8(seed * 255)

View file

@ -46,7 +46,7 @@ func TestName(t *testing.T) {
audioWg.Add(iterations)
frame := genFrame(100, 100)
for i := 0; i < 222; i++ {
for range 222 {
go func() {
recorder.WriteVideo(Video{Frame: frame, Duration: 16 * time.Millisecond})
imgWg.Done()
@ -134,8 +134,8 @@ func benchmarkRecorder(w, h int, b *testing.B) {
func genFrame(w, h int) Frame {
img := image.NewRGBA(image.Rect(0, 0, w, h))
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
for x := range w {
for y := range h {
img.Set(x, y, randomColor())
}
}