mutable decl syntax change

This commit is contained in:
2026-08-05 21:19:41 +02:00
parent 88b94197c9
commit 081a3fd5df
74 changed files with 870 additions and 733 deletions
+8 -8
View File
@@ -19,8 +19,8 @@ init func($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) {
compile_error!("static string map has too many entries")
}
keys [N]mut []u8 = undefined
values [N]mut V = undefined
keys [N]mut []u8 := undefined
values [N]mut V := undefined
# assert no duplicate keys
for entries |entry, i| {
@@ -37,7 +37,7 @@ init func($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) {
}
if N == 0 {
len_indexes [0]u32 = undefined
len_indexes [0]u32 := undefined
return StaticStringMap(V){
keys = keys[..],
values = values[..],
@@ -51,7 +51,7 @@ init func($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) {
for 1..N |i| {
key :: keys[i]
value :: values[i]
j usize = i
j usize := i
while j > 0 and keys[j - 1].len > key.len : j -= 1 {
keys[j] = keys[j - 1]
values[j] = values[j - 1]
@@ -62,8 +62,8 @@ init func($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) {
min_len u32 :: u32(keys[0].len)
max_len u32 :: u32(keys[N - 1].len)
len_indexes [usize(max_len) + 1]mut u32 = undefined
entry_index usize = 0
len_indexes [usize(max_len) + 1]mut u32 := undefined
entry_index usize := 0
for 0..=usize(max_len) |length| {
while entry_index < N and keys[entry_index].len < length : entry_index += 1 {}
len_indexes[length] = u32(entry_index)
@@ -81,10 +81,10 @@ init func($V type, $N usize, $entries [N]Pair(V)) StaticStringMap(V) {
get func($V type, map @StaticStringMap(V), key []u8) ?V {
if (map.keys.len == 0 or key.len > maxval!(u32)) return null
length u32 = u32(key.len)
length u32 := u32(key.len)
if (length < map.min_len or length > map.max_len) return null
idx usize = usize(map.len_indexes[usize(length)])
idx usize := usize(map.len_indexes[usize(length)])
while idx < map.keys.len : idx += 1 {
candidate :: map.keys[idx]
if (candidate.len != key.len) return null