From 239b52ad84c02379347e609baa341e1ca1a42678 Mon Sep 17 00:00:00 2001 From: saxon Date: Fri, 14 Dec 2018 16:37:13 +1030 Subject: [PATCH] psi: simplified LocationStrBytes --- stream/mts/psi/op.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stream/mts/psi/op.go b/stream/mts/psi/op.go index 55f9df8d..331019b7 100644 --- a/stream/mts/psi/op.go +++ b/stream/mts/psi/op.go @@ -105,10 +105,13 @@ func LocationFrom(p []byte) (g string, err error) { // LocationStrBytes take a string of location data and converts to a 32 byte slice - // easy update of slice representation of a pmt with location descriptor -func LocationStrBytes(l string) (out []byte) { - out = make([]byte, locationDataSize) - copy(out, []byte(l)) - return +func LocationStrBytes(s string) []byte { + if len(s) != locationDataSize { + panic("Location string not the right size") + } + var b [locationDataSize]byte + copy(b[:], s) + return b[:] } // UpdateLocation takes a byte slice representation of a psi-pmt containing a location