Removed unnecessary conversions.

This commit is contained in:
scruzin 2019-01-13 16:18:25 +10:30
parent a8572722b5
commit 137ff7990a
2 changed files with 9 additions and 9 deletions

View File

@ -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:

View File

@ -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 {