refactor(dvrip): simplify broadcast loop structure

- replace traditional for loop with range-based for loop for clarity

refactor(ffmpeg): simplify cut function loop
- utilize range-based for loop instead of traditional for loop

refactor(ring): update API response mapping type
- change map type from `interface{}` to `any` for better type safety

refactor(stream): handle nil source in NewStream
- add nil check for source elements before processing

refactor(webrtc): unify payload handling in GetToken
- change map type from `interface{}` to `any` for consistency

refactor(ascii): optimize nested loops in Write function
- replace traditional for loops with range-based for loops for readability

refactor(bits): enhance readability in Reader methods
- replace traditional for loops with range-based for loops in Read functions

refactor(h264): modernize loop structures in DecodeConfig
- switch to range-based for loops for cleaner code

refactor(h265): streamline profile_tier_level loops
- utilize range-based for loops instead of traditional for loops

chore(core): remove commented-out test function for clarity

refactor(core): simplify RandString function loop
- change traditional for loop to range-based for loop

refactor(flvt): optimize timestamp handling in TestTimeToRTP
- switch to range-based for loop for iterating frames

refactor(nest): improve error handling in ExchangeSDP
- format error message with printf-style formatting for clarity

refactor(tapo): enhance securityEncode function
- change traditional for loop to range-based for loop for readability

fix(tcp): correct masking in websocket Write method
- replace traditional for loop with range-based for loop

refactor(tutk): modernize encoding loops in crypto functions
- utilize range-based for loops for better readability

refactor(tuya): unify data types in MQTT message struct
- change map type from `interface{}` to `any` for consistency

refactor(webrtc): standardize codec registration
- change map type from `interface{}` to `any` for type safety

refactor(yaml): simplify Unmarshal function signature
- update parameter type from `interface{}` to `any` for better clarity
This commit is contained in:
Sergey Krashevich
2026-03-10 23:26:45 +03:00
parent 319fc3a154
commit 2b7682cdb3
42 changed files with 120 additions and 133 deletions
+7 -7
View File
@@ -14,7 +14,7 @@ func NewReader(b []byte) *Reader {
}
//goland:noinspection GoStandardMethods
func (r *Reader) ReadByte() byte {
func (r *Reader) ReadUint8() byte {
if r.bits != 0 {
return r.ReadBits8(8)
}
@@ -33,26 +33,26 @@ func (r *Reader) ReadUint16() uint16 {
if r.bits != 0 {
return r.ReadBits16(16)
}
return uint16(r.ReadByte())<<8 | uint16(r.ReadByte())
return uint16(r.ReadUint8())<<8 | uint16(r.ReadUint8())
}
func (r *Reader) ReadUint24() uint32 {
if r.bits != 0 {
return r.ReadBits(24)
}
return uint32(r.ReadByte())<<16 | uint32(r.ReadByte())<<8 | uint32(r.ReadByte())
return uint32(r.ReadUint8())<<16 | uint32(r.ReadUint8())<<8 | uint32(r.ReadUint8())
}
func (r *Reader) ReadUint32() uint32 {
if r.bits != 0 {
return r.ReadBits(32)
}
return uint32(r.ReadByte())<<24 | uint32(r.ReadByte())<<16 | uint32(r.ReadByte())<<8 | uint32(r.ReadByte())
return uint32(r.ReadUint8())<<24 | uint32(r.ReadUint8())<<16 | uint32(r.ReadUint8())<<8 | uint32(r.ReadUint8())
}
func (r *Reader) ReadBit() byte {
if r.bits == 0 {
r.byte = r.ReadByte()
r.byte = r.ReadUint8()
r.bits = 7
} else {
r.bits--
@@ -106,8 +106,8 @@ func (r *Reader) ReadBytes(n int) (b []byte) {
r.pos += n
} else {
b = make([]byte, n)
for i := 0; i < n; i++ {
b[i] = r.ReadByte()
for i := range n {
b[i] = r.ReadUint8()
}
}
+3 -3
View File
@@ -11,7 +11,7 @@ func NewWriter(buf []byte) *Writer {
}
//goland:noinspection GoStandardMethods
func (w *Writer) WriteByte(b byte) {
func (w *Writer) WriteUint8(b byte) {
if w.bits != 0 {
w.WriteBits8(b, 8)
}
@@ -50,7 +50,7 @@ func (w *Writer) WriteBits8(v, n byte) {
}
func (w *Writer) WriteAllBits(bit, n byte) {
for i := byte(0); i < n; i++ {
for range n {
w.WriteBit(bit)
}
}
@@ -74,7 +74,7 @@ func (w *Writer) WriteUint16(v uint16) {
func (w *Writer) WriteBytes(bytes ...byte) {
if w.bits != 0 {
for _, b := range bytes {
w.WriteByte(b)
w.WriteUint8(b)
}
}