commit b42f3743957c915b7d3f33a3d80f94f95fe1bedf
parent 632d4d1a3eefc7c7ce0d09802d97ab4ae402b9f7
Author: Oliver Lowe <o@olowe.co>
Date: Mon, 13 May 2024 16:04:32 +1000
internal/scte35: use copy() builtin rather than assigning bytes
May as well use what the stdlib gives us.
Diffstat:
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/internal/scte35/command.go b/internal/scte35/command.go
@@ -64,7 +64,7 @@ func encodeCommand(c *Command) ([]byte, error) {
return b, nil
case TimeSignal:
if c.TimeSignal == nil {
- return nil, fmt.Errorf("command type is %s, but nil TimeSignal value set", c.Type)
+ return nil, fmt.Errorf("cannot encode nil TimeSignal")
}
b := encodeSpliceTime(*c.TimeSignal)
return b[:], nil
@@ -159,11 +159,7 @@ type PrivateCommand struct {
func encodePrivateCommand(c *PrivateCommand) []byte {
buf := make([]byte, 4+len(c.Data))
binary.BigEndian.PutUint32(buf[:4], c.ID)
- i := 4
- for j := range c.Data {
- buf[i] = c.Data[j]
- i++
- }
+ copy(buf[4:], c.Data)
return buf
}
diff --git a/internal/scte35/splice_descriptor.go b/internal/scte35/splice_descriptor.go
@@ -72,11 +72,7 @@ func (d DTMFDescriptor) Data() []byte {
b[0] = byte(d.Preroll)
// set 3 bits, right-most 5 are reserved.
b[1] = byte(len(d.Chars)) << 5
- i := 2
- for j := range d.Chars {
- b[i] = d.Chars[j]
- i++
- }
+ copy(b[2:], d.Chars)
return b
}