mirror of https://bitbucket.org/ausocean/av.git
Removed unnecessary conversions.
This commit is contained in:
parent
a8572722b5
commit
137ff7990a
|
@ -93,7 +93,7 @@ var (
|
||||||
|
|
||||||
// DecodeInt16 decodes a 16-bit integer.
|
// DecodeInt16 decodes a 16-bit integer.
|
||||||
func DecodeInt16(buf []byte) uint16 {
|
func DecodeInt16(buf []byte) uint16 {
|
||||||
return uint16(binary.BigEndian.Uint16(buf))
|
return binary.BigEndian.Uint16(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeInt24 decodes a 24-bit integer.
|
// DecodeInt24 decodes a 24-bit integer.
|
||||||
|
@ -103,12 +103,12 @@ func DecodeInt24(buf []byte) uint32 {
|
||||||
|
|
||||||
// DecodeInt32 decodes a 32-bit integer.
|
// DecodeInt32 decodes a 32-bit integer.
|
||||||
func DecodeInt32(buf []byte) uint32 {
|
func DecodeInt32(buf []byte) uint32 {
|
||||||
return uint32(binary.BigEndian.Uint32(buf))
|
return binary.BigEndian.Uint32(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeInt32LE decodes a 32-bit little-endian integer.
|
// DecodeInt32LE decodes a 32-bit little-endian integer.
|
||||||
func DecodeInt32LE(buf []byte) uint32 {
|
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.
|
// 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.Name = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
prop.Type = uint8(buf[0])
|
prop.Type = buf[0]
|
||||||
buf = buf[1:]
|
buf = buf[1:]
|
||||||
|
|
||||||
switch prop.Type {
|
switch prop.Type {
|
||||||
|
@ -311,7 +311,7 @@ func DecodeProperty(prop *Property, buf []byte, decodeName bool) (int, error) {
|
||||||
if len(buf) < 1 {
|
if len(buf) < 1 {
|
||||||
return 0, ErrShortBuffer
|
return 0, ErrShortBuffer
|
||||||
}
|
}
|
||||||
prop.Number = float64(uint8(buf[0]))
|
prop.Number = float64(buf[0])
|
||||||
buf = buf[1:]
|
buf = buf[1:]
|
||||||
|
|
||||||
case typeString:
|
case typeString:
|
||||||
|
|
|
@ -163,11 +163,11 @@ func TestObject(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the encoding
|
// Check the encoding
|
||||||
if uint8(buf[0]) != TypeObject {
|
if buf[0] != TypeObject {
|
||||||
t.Errorf("Encoded wrong type; expected %d, got %v", TypeObject, uint8(buf[0]))
|
t.Errorf("Encoded wrong type; expected %d, got %v", TypeObject, buf[0])
|
||||||
}
|
}
|
||||||
if uint8(buf[1]) != typeNumber {
|
if buf[1] != typeNumber {
|
||||||
t.Errorf("Encoded wrong type; expected %d, got %v", typeNumber, uint8(buf[0]))
|
t.Errorf("Encoded wrong type; expected %d, got %v", typeNumber, buf[0])
|
||||||
}
|
}
|
||||||
num := DecodeNumber(buf[2:10])
|
num := DecodeNumber(buf[2:10])
|
||||||
if num != 42 {
|
if num != 42 {
|
||||||
|
|
Loading…
Reference in New Issue