mutable decl syntax change
This commit is contained in:
@@ -59,7 +59,7 @@ get func(
|
||||
if (map.count == 0) return null
|
||||
|
||||
hash :: normalize(hash_key(key))
|
||||
idx usize = hash & (map.entries.len - 1)
|
||||
idx usize := hash & (map.entries.len - 1)
|
||||
|
||||
while true {
|
||||
entry :: map.entries[idx]
|
||||
@@ -98,7 +98,7 @@ put func(
|
||||
if (entry.hash == 0) continue
|
||||
|
||||
# find an empty slot
|
||||
idx usize = entry.hash & (new_entries.len - 1)
|
||||
idx usize := entry.hash & (new_entries.len - 1)
|
||||
while new_entries[idx].hash != 0 {
|
||||
idx = (idx + 1) & (new_entries.len - 1)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ put func(
|
||||
|
||||
# put new entry
|
||||
hash :: normalize(hash_key(key))
|
||||
idx usize = hash & (map.entries.len - 1)
|
||||
idx usize := hash & (map.entries.len - 1)
|
||||
|
||||
while true {
|
||||
entry :: map.entries[idx]
|
||||
@@ -144,8 +144,8 @@ hide normalize func(hash usize) usize {
|
||||
#! FNV-1a hash implementation.
|
||||
#! note: vulnerable to collision attacks.
|
||||
hide str_hash func(key []u8) usize {
|
||||
hash u32 = 2166136261 # offset basis
|
||||
prime u32 = 16777619
|
||||
hash u32 := 2166136261 # offset basis
|
||||
prime u32 := 16777619
|
||||
|
||||
for key |byte| {
|
||||
product u64 :: u64(hash xor u32(byte)) * prime
|
||||
|
||||
Reference in New Issue
Block a user