Skip to content

Commit ae2a85f

Browse files
committed
Apply go modernize
1 parent 3cb438f commit ae2a85f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

pkg/nack/generator_interceptor.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package nack
55

66
import (
77
"math/rand"
8+
"slices"
89
"sync"
910
"time"
1011

@@ -197,14 +198,7 @@ func (n *GeneratorInterceptor) loop(rtcpWriter interceptor.RTCPWriter) {
197198
}
198199

199200
for nackSeq := range n.nackCountLogs[ssrc] {
200-
isMissing := false
201-
for _, missingSeq := range missing {
202-
if missingSeq == nackSeq {
203-
isMissing = true
204-
205-
break
206-
}
207-
}
201+
isMissing := slices.Contains(missing, nackSeq)
208202
if !isMissing {
209203
delete(n.nackCountLogs[ssrc], nackSeq)
210204
}

pkg/stats/stats_recorder.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package stats
55

66
import (
7+
"slices"
78
"sync"
89
"sync/atomic"
910
"time"
@@ -291,13 +292,7 @@ func (r *recorder) recordIncomingXR(latestStats internalStats, pkt *rtcp.Extende
291292
}
292293

293294
func contains(ls []uint32, e uint32) bool {
294-
for _, x := range ls {
295-
if x == e {
296-
return true
297-
}
298-
}
299-
300-
return false
295+
return slices.Contains(ls, e)
301296
}
302297

303298
func (r *recorder) recordIncomingRTCP(latestStats internalStats, incoming *incomingRTCP) internalStats {

0 commit comments

Comments
 (0)