migrate to new mutable decl syntax

This commit is contained in:
2026-08-05 21:53:09 +02:00
parent 1689c4db3c
commit 410246faee
20 changed files with 116 additions and 112 deletions
+5 -5
View File
@@ -59,7 +59,7 @@ get proc(
if (map.count == 0) return null
hash :: normalize(hash_key(key))
idx usize = hash & (map.entries.len - 1)
idx := hash & (map.entries.len - 1)
while true {
entry :: map.entries[idx]
@@ -96,7 +96,7 @@ put proc(
if (entry.hash == 0) continue
# find an empty slot
idx usize = entry.hash & (new_entries.len - 1)
idx := entry.hash & (new_entries.len - 1)
while new_entries[idx].hash != 0 {
idx = (idx + 1) & (new_entries.len - 1)
}
@@ -110,7 +110,7 @@ put proc(
# put new entry
hash :: normalize(hash_key(key))
idx usize = hash & (map.entries.len - 1)
idx := hash & (map.entries.len - 1)
while true {
entry :: map.entries[idx]
@@ -142,8 +142,8 @@ hide normalize proc(hash usize) usize {
#! FNV-1a hash implementation.
#! note: vulnerable to collision attacks.
hide str_hash proc(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