mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
encoding.binary: removed unneeded castings, rename function
This commit is contained in:
parent
cb3ac33e18
commit
74713ffb62
@ -4,9 +4,9 @@
|
|||||||
module binary
|
module binary
|
||||||
// Little Endian
|
// Little Endian
|
||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_endian_u16(b []byte) u16 {
|
pub fn little_endian_u16(b []byte) u16 {
|
||||||
_ = b[1] // bounds check
|
_ = b[1] // bounds check
|
||||||
return u16(b[0]) | u16(u16(b[1])<<u16(8))
|
return u16(b[0]) | (u16(b[1])<<u16(8))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
@ -19,7 +19,7 @@ pub fn little_endian_put_u16(b mut []byte, v u16) {
|
|||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_u32(b []byte) u32 {
|
pub fn little_endian_u32(b []byte) u32 {
|
||||||
_ = b[3] // bounds check
|
_ = b[3] // bounds check
|
||||||
return u32(b[0]) | u32(u32(b[1])<<u32(8)) | u32(u32(b[2])<<u32(16)) | u32(u32(b[3])<<u32(24))
|
return u32(b[0]) | (u32(b[1])<<u32(8)) | (u32(b[2])<<u32(16)) | (u32(b[3])<<u32(24))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
@ -34,7 +34,7 @@ pub fn little_endian_put_u32(b mut []byte, v u32) {
|
|||||||
[inline]
|
[inline]
|
||||||
pub fn little_endian_u64(b []byte) u64 {
|
pub fn little_endian_u64(b []byte) u64 {
|
||||||
_ = b[7] // bounds check
|
_ = b[7] // bounds check
|
||||||
return u64(b[0]) | u64(u64(b[1])<<u64(8)) | u64(u64(b[2])<<u64(16)) | u64(u64(b[3])<<u64(24)) | u64(u64(b[4])<<u64(32)) | u64(u64(b[5])<<u64(40)) | u64(u64(b[6])<<u64(48)) | u64(u64(b[7])<<u64(56))
|
return u64(b[0]) | (u64(b[1])<<u64(8)) | (u64(b[2])<<u64(16)) | (u64(b[3])<<u64(24)) | (u64(b[4])<<u64(32)) | (u64(b[5])<<u64(40)) | (u64(b[6])<<u64(48)) | (u64(b[7])<<u64(56))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
@ -54,7 +54,7 @@ pub fn little_endian_put_u64(b mut []byte, v u64) {
|
|||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_u16(b []byte) u16 {
|
pub fn big_endian_u16(b []byte) u16 {
|
||||||
_ = b[1] // bounds check
|
_ = b[1] // bounds check
|
||||||
return u16(b[1]) | u16(u16(b[0])<<u16(8))
|
return u16(b[1]) | (u16(b[0])<<u16(8))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
@ -67,7 +67,7 @@ pub fn big_endian_put_u16(b mut []byte, v u16) {
|
|||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_u32(b []byte) u32 {
|
pub fn big_endian_u32(b []byte) u32 {
|
||||||
_ = b[3] // bounds check
|
_ = b[3] // bounds check
|
||||||
return u32(b[3]) | u32(u32(b[2])<<u32(8)) | u32(u32(b[1])<<u32(16)) | u32(u32(b[0])<<u32(24))
|
return u32(b[3]) | (u32(b[2])<<u32(8)) | (u32(b[1])<<u32(16)) | (u32(b[0])<<u32(24))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
@ -82,7 +82,7 @@ pub fn big_endian_put_u32(b mut []byte, v u32) {
|
|||||||
[inline]
|
[inline]
|
||||||
pub fn big_endian_u64(b []byte) u64 {
|
pub fn big_endian_u64(b []byte) u64 {
|
||||||
_ = b[7] // bounds check
|
_ = b[7] // bounds check
|
||||||
return u64(b[7]) | u64(u64(b[6])<<u64(8)) | u64(u64(b[5])<<u64(16)) | u64(u64(b[4])<<u64(24)) | u64(u64(b[3])<<u64(32)) | u64(u64(b[2])<<u64(40)) | u64(u64(b[1])<<u64(48)) | u64(u64(b[0])<<u64(56))
|
return u64(b[7]) | (u64(b[6])<<u64(8))| (u64(b[5])<<u64(16)) | (u64(b[4])<<u64(24)) | (u64(b[3])<<u64(32)) | (u64(b[2])<<u64(40)) | (u64(b[1])<<u64(48)) | (u64(b[0])<<u64(56))
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user