summaryrefslogtreecommitdiff
path: root/uscript/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'uscript/map.c')
-rw-r--r--uscript/map.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/uscript/map.c b/uscript/map.c
index 01f2462..d1f4da6 100644
--- a/uscript/map.c
+++ b/uscript/map.c
@@ -14,7 +14,7 @@ uint32_t hash_val(struct us_val v)
return *(uint32_t*)&n;
}
case VAL_BOOL: return get_bool(v) ? 1 : 0;
- case VAL_ZILCH: return 2;
+ case VAL_NADA: return 2;
case VAL_STR: // TODO: string should use a different hash function
case VAL_ARR:
case VAL_MAP:
@@ -30,8 +30,8 @@ uint32_t hash_val(struct us_val v)
static
struct us_map_kv *find_entry(struct us_map_kv *map, int cap, struct us_val k)
{
- if (k.type == VAL_ZILCH) {
- us_err("use of zilch as a map key");
+ if (k.type == VAL_NADA) {
+ us_err("use of nada as a map key");
}
uint32_t hash = hash_val(k);
@@ -41,8 +41,8 @@ struct us_map_kv *find_entry(struct us_map_kv *map, int cap, struct us_val k)
while (true) {
struct us_map_kv *item = &map[i];
- if (item->key.type == VAL_ZILCH) {
- if (item->val.type == VAL_ZILCH) {
+ if (item->key.type == VAL_NADA) {
+ if (item->val.type == VAL_NADA) {
return ts ? ts : item;
} else if (ts == NULL) {
ts = item;
@@ -60,14 +60,14 @@ void grow_map(struct us_map *map, int new_cap)
{
struct us_map_kv *new = mem_alloc(sizeof(struct us_map_kv) * new_cap);
for (int i = 0; i < new_cap; i++) {
- new[i].key = create_zilch();
- new[i].val = create_zilch();
+ new[i].key = create_nada();
+ new[i].val = create_nada();
}
map->len = 0;
for (int i = 0; i < map->cap; i++) {
struct us_map_kv *item = &map->e[i];
- if (item->key.type == VAL_ZILCH)
+ if (item->key.type == VAL_NADA)
continue;
struct us_map_kv *dst = find_entry(new, new_cap, item->key);
@@ -102,7 +102,7 @@ void map_set_value(struct us_map *map, struct us_val k, struct us_val v)
}
struct us_map_kv *kv = find_entry(map->e, map->cap, k);
- if (kv->key.type == VAL_ZILCH) {
+ if (kv->key.type == VAL_NADA) {
if (val_as_bool(map->locked))
us_err("attempt to modify keylocked map");
map->len++;
@@ -130,7 +130,7 @@ bool map_get_value(struct us_map *map, struct us_val k, struct us_val *v)
}
struct us_map_kv *kv = find_entry(map->e, map->cap, k);
- if (kv->key.type == VAL_ZILCH)
+ if (kv->key.type == VAL_NADA)
goto fail;
if (v)
@@ -138,6 +138,6 @@ bool map_get_value(struct us_map *map, struct us_val k, struct us_val *v)
return true;
fail:
if (v)
- *v = create_zilch();
+ *v = create_nada();
return false;
}