mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: replace []byte with []u8
This commit is contained in:
@@ -37,7 +37,7 @@ fn (mut c Crc32) generate_table(poly int) {
|
||||
}
|
||||
}
|
||||
|
||||
fn (c &Crc32) sum32(b []byte) u32 {
|
||||
fn (c &Crc32) sum32(b []u8) u32 {
|
||||
mut crc := ~u32(0)
|
||||
for i in 0 .. b.len {
|
||||
crc = c.table[u8(crc) ^ b[i]] ^ (crc >> 8)
|
||||
@@ -45,7 +45,7 @@ fn (c &Crc32) sum32(b []byte) u32 {
|
||||
return ~crc
|
||||
}
|
||||
|
||||
pub fn (c &Crc32) checksum(b []byte) u32 {
|
||||
pub fn (c &Crc32) checksum(b []u8) u32 {
|
||||
return c.sum32(b)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ pub fn new(poly int) &Crc32 {
|
||||
}
|
||||
|
||||
// calculate crc32 using ieee
|
||||
pub fn sum(b []byte) u32 {
|
||||
pub fn sum(b []u8) u32 {
|
||||
c := new(int(crc32.ieee))
|
||||
return c.sum32(b)
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ pub fn sum32_string(data string) u32 {
|
||||
// sum32 returns a fnv1a hash of the memory block, described by the dynamic
|
||||
// byte array `data`.
|
||||
[direct_array_access; inline]
|
||||
pub fn sum32(data []byte) u32 {
|
||||
pub fn sum32(data []u8) u32 {
|
||||
mut hash := fnv1a.fnv32_offset_basis
|
||||
for i in 0 .. data.len {
|
||||
hash = (hash ^ u32(data[i])) * fnv1a.fnv32_prime
|
||||
@@ -67,7 +67,7 @@ pub fn sum64_string(data string) u64 {
|
||||
// sum64 returns a fnv1a hash of the memory block, described by the dynamic
|
||||
// byte array `data`.
|
||||
[direct_array_access; inline]
|
||||
pub fn sum64(data []byte) u64 {
|
||||
pub fn sum64(data []u8) u64 {
|
||||
mut hash := fnv1a.fnv64_offset_basis
|
||||
for i in 0 .. data.len {
|
||||
hash = (hash ^ u64(data[i])) * fnv1a.fnv64_prime
|
||||
|
@@ -6,7 +6,7 @@ module hash
|
||||
interface Hasher {
|
||||
// Sum appends the current hash to b and returns the resulting array.
|
||||
// It does not change the underlying hash state.
|
||||
sum(b []byte) []byte
|
||||
sum(b []u8) []u8
|
||||
size() int
|
||||
block_size() int
|
||||
}
|
||||
|
@@ -22,6 +22,6 @@ pub fn sum64_string(key string, seed u64) u64 {
|
||||
}
|
||||
|
||||
[inline]
|
||||
pub fn sum64(key []byte, seed u64) u64 {
|
||||
pub fn sum64(key []u8, seed u64) u64 {
|
||||
return wyhash_c(&u8(key.data), u64(key.len), seed)
|
||||
}
|
||||
|
Reference in New Issue
Block a user