From 137ff7990aa6e1a5e063adec6aaadd317cb9fcf8 Mon Sep 17 00:00:00 2001 From: scruzin Date: Sun, 13 Jan 2019 16:18:25 +1030 Subject: [PATCH] Removed unnecessary conversions. --- rtmp/amf/amf.go | 10 +++++----- rtmp/amf/amf_test.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rtmp/amf/amf.go b/rtmp/amf/amf.go index 190f8f74..196dac10 100644 --- a/rtmp/amf/amf.go +++ b/rtmp/amf/amf.go @@ -93,7 +93,7 @@ var ( // DecodeInt16 decodes a 16-bit integer. func DecodeInt16(buf []byte) uint16 { - return uint16(binary.BigEndian.Uint16(buf)) + return binary.BigEndian.Uint16(buf) } // DecodeInt24 decodes a 24-bit integer. @@ -103,12 +103,12 @@ func DecodeInt24(buf []byte) uint32 { // DecodeInt32 decodes a 32-bit integer. func DecodeInt32(buf []byte) uint32 { - return uint32(binary.BigEndian.Uint32(buf)) + return binary.BigEndian.Uint32(buf) } // DecodeInt32LE decodes a 32-bit little-endian integer. func DecodeInt32LE(buf []byte) uint32 { - return uint32(binary.LittleEndian.Uint32(buf)) + return binary.LittleEndian.Uint32(buf) } // DecodeString decodes a string that is less than 2^16 bytes long. @@ -296,7 +296,7 @@ func DecodeProperty(prop *Property, buf []byte, decodeName bool) (int, error) { prop.Name = "" } - prop.Type = uint8(buf[0]) + prop.Type = buf[0] buf = buf[1:] switch prop.Type { @@ -311,7 +311,7 @@ func DecodeProperty(prop *Property, buf []byte, decodeName bool) (int, error) { if len(buf) < 1 { return 0, ErrShortBuffer } - prop.Number = float64(uint8(buf[0])) + prop.Number = float64(buf[0]) buf = buf[1:] case typeString: diff --git a/rtmp/amf/amf_test.go b/rtmp/amf/amf_test.go index 4a0d19e1..04cc1ebc 100644 --- a/rtmp/amf/amf_test.go +++ b/rtmp/amf/amf_test.go @@ -163,11 +163,11 @@ func TestObject(t *testing.T) { } // Check the encoding - if uint8(buf[0]) != TypeObject { - t.Errorf("Encoded wrong type; expected %d, got %v", TypeObject, uint8(buf[0])) + if buf[0] != TypeObject { + t.Errorf("Encoded wrong type; expected %d, got %v", TypeObject, buf[0]) } - if uint8(buf[1]) != typeNumber { - t.Errorf("Encoded wrong type; expected %d, got %v", typeNumber, uint8(buf[0])) + if buf[1] != typeNumber { + t.Errorf("Encoded wrong type; expected %d, got %v", typeNumber, buf[0]) } num := DecodeNumber(buf[2:10]) if num != 42 {