mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Create optional with ~ instead of ?. return io::EOF?; becomes return io::EOF~.
- Deprecated use of `?` to create optional.
This commit is contained in:
@@ -35,17 +35,17 @@ fn void Map.init(Map *map, uint capacity = 128)
|
||||
|
||||
fn Type? Map.valueForKey(Map *map, Key key)
|
||||
{
|
||||
if (!map.map) return faults::KEY_NOT_FOUND?;
|
||||
if (!map.map) return faults::KEY_NOT_FOUND~;
|
||||
uint hash = key.hash();
|
||||
usz pos = hash & map.mod;
|
||||
Entry* entry = &map.map[pos];
|
||||
if (!entry) return faults::KEY_NOT_FOUND?;
|
||||
if (!entry) return faults::KEY_NOT_FOUND~;
|
||||
while (entry)
|
||||
{
|
||||
if (entry.hash == hash && entry.key == key) return entry.value;
|
||||
entry = entry.next;
|
||||
}
|
||||
return faults::KEY_NOT_FOUND?;
|
||||
return faults::KEY_NOT_FOUND~;
|
||||
}
|
||||
|
||||
fn Type? Map.set(Map *map, Key key, Type value) @maydiscard
|
||||
@@ -67,7 +67,7 @@ fn Type? Map.set(Map *map, Key key, Type value) @maydiscard
|
||||
entry.value = value;
|
||||
entry.hash = hash;
|
||||
entry.key = key;
|
||||
return faults::KEY_NOT_FOUND?;
|
||||
return faults::KEY_NOT_FOUND~;
|
||||
}
|
||||
if (entry.hash == hash && entry.key == key)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ fn Type? Map.set(Map *map, Key key, Type value) @maydiscard
|
||||
new.next = null;
|
||||
new.used = true;
|
||||
entry.next = new;
|
||||
return faults::KEY_NOT_FOUND?;
|
||||
return faults::KEY_NOT_FOUND~;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user