mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cleanup: replace C for loops with range
This commit is contained in:
@ -24,9 +24,9 @@ mut:
|
||||
}
|
||||
|
||||
fn(c mut Crc32) generate_table(poly int) {
|
||||
for i := 0; i < 256; i++ {
|
||||
for i in 0..256 {
|
||||
mut crc := u32(i)
|
||||
for j := 0; j < 8; j++ {
|
||||
for j in 0..8 {
|
||||
if crc & u32(1) == u32(1) {
|
||||
crc = (crc >> 1) ^ u32(poly)
|
||||
} else {
|
||||
@ -39,7 +39,7 @@ fn(c mut Crc32) generate_table(poly int) {
|
||||
|
||||
fn(c &Crc32) sum32(b []byte) u32 {
|
||||
mut crc := ~u32(0)
|
||||
for i := 0; i < b.len; i++ {
|
||||
for i in 0..b.len {
|
||||
crc = c.table[byte(crc)^b[i]] ^ u32(crc >> u32(8))
|
||||
}
|
||||
return ~crc
|
||||
|
@ -10,7 +10,7 @@ const (
|
||||
[inline]
|
||||
pub fn sum32_string(data string) u32 {
|
||||
mut hash := fnv32_offset_basis
|
||||
for i := 0; i < data.len; i++ {
|
||||
for i in 0..data.len {
|
||||
hash = (hash ^ u32(data[i])) * fnv32_prime
|
||||
}
|
||||
return hash
|
||||
@ -19,7 +19,7 @@ pub fn sum32_string(data string) u32 {
|
||||
[inline]
|
||||
pub fn sum32(data []byte) u32 {
|
||||
mut hash := fnv32_offset_basis
|
||||
for i := 0; i < data.len; i++ {
|
||||
for i in 0..data.len {
|
||||
hash = (hash ^ u32(data[i])) * fnv32_prime
|
||||
}
|
||||
return hash
|
||||
@ -28,7 +28,7 @@ pub fn sum32(data []byte) u32 {
|
||||
[inline]
|
||||
pub fn sum64_string(data string) u64 {
|
||||
mut hash := fnv64_offset_basis
|
||||
for i := 0; i < data.len; i++ {
|
||||
for i in 0..data.len {
|
||||
hash = (hash ^ u64(data[i])) * fnv64_prime
|
||||
}
|
||||
return hash
|
||||
@ -37,7 +37,7 @@ pub fn sum64_string(data string) u64 {
|
||||
[inline]
|
||||
pub fn sum64(data []byte) u64 {
|
||||
mut hash := fnv64_offset_basis
|
||||
for i := 0; i < data.len; i++ {
|
||||
for i in 0..data.len {
|
||||
hash = (hash ^ u64(data[i])) * fnv64_prime
|
||||
}
|
||||
return hash
|
||||
|
Reference in New Issue
Block a user