mirror of https://github.com/rui314/9cc.git
Remove map_exists().
This commit is contained in:
parent
78c11d5434
commit
7343d9a9d4
16
parse.c
16
parse.c
|
@ -29,16 +29,20 @@ static Env *new_env(Env *next) {
|
|||
}
|
||||
|
||||
static Type *find_typedef(char *name) {
|
||||
for (Env *e = env; e; e = e->next)
|
||||
if (map_exists(e->typedefs, name))
|
||||
return map_get(e->typedefs, name);
|
||||
for (Env *e = env; e; e = e->next) {
|
||||
Type *ty = map_get(e->typedefs, name);
|
||||
if (ty)
|
||||
return ty;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Type *find_tag(char *name) {
|
||||
for (Env *e = env; e; e = e->next)
|
||||
if (map_exists(e->tags, name))
|
||||
return map_get(e->tags, name);
|
||||
for (Env *e = env; e; e = e->next) {
|
||||
Type *ty = map_get(e->tags, name);
|
||||
if (ty)
|
||||
return ty;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
7
util.c
7
util.c
|
@ -63,13 +63,6 @@ int map_geti(Map *map, char *key, int default_) {
|
|||
return default_;
|
||||
}
|
||||
|
||||
bool map_exists(Map *map, char *key) {
|
||||
for (int i = map->keys->len - 1; i >= 0; i--)
|
||||
if (!strcmp(map->keys->data[i], key))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
StringBuilder *new_sb(void) {
|
||||
StringBuilder *sb = malloc(sizeof(StringBuilder));
|
||||
sb->data = malloc(8);
|
||||
|
|
|
@ -43,9 +43,6 @@ static void map_test() {
|
|||
|
||||
map_put(map, "foo", (void *)6);
|
||||
expect(__LINE__, 6, (intptr_t)map_get(map, "foo"));
|
||||
|
||||
expect(__LINE__, true, map_exists(map, "foo"));
|
||||
expect(__LINE__, false, map_exists(map, "baz"));
|
||||
}
|
||||
|
||||
static void sb_test() {
|
||||
|
|
Loading…
Reference in New Issue