cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit d02201ec74d5d6f54bf1980317be45e1e5aef21c
parent f4d1b8acc04c4f2beeffafa8ff1cca0bdfbe71b2
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 17 Apr 2019 20:03:44 -0700

Just use a single mapkey function

Diffstat:
Mdecl.c | 2+-
Mmap.c | 8+-------
Mmap.h | 3+--
Mqbe.c | 2+-
Mscope.c | 8++++----
5 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/decl.c b/decl.c @@ -962,7 +962,7 @@ struct decl *stringdecl(struct expr *expr) if (!strings) strings = mkmap(64); assert(expr->kind == EXPRSTRING); - mapbufkey(&key, expr->string.data, expr->string.size); + mapkey(&key, expr->string.data, expr->string.size); entry = mapput(strings, &key); d = *entry; if (!d) { diff --git a/map.c b/map.c @@ -25,19 +25,13 @@ hash(const void *ptr, size_t len) } void -mapbufkey(struct mapkey *k, const char *s, size_t n) +mapkey(struct mapkey *k, const char *s, size_t n) { k->str = s; k->len = n; k->hash = hash(s, n); } -void -mapstrkey(struct mapkey *k, const char *s) -{ - mapbufkey(k, s, strlen(s)); -} - struct map * mkmap(size_t cap) { diff --git a/map.h b/map.h @@ -4,8 +4,7 @@ struct mapkey { size_t len; }; -void mapstrkey(struct mapkey *, const char *); -void mapbufkey(struct mapkey *, const char *, size_t); +void mapkey(struct mapkey *, const char *, size_t); struct map *mkmap(size_t); void delmap(struct map *, void(void *)); diff --git a/qbe.c b/qbe.c @@ -462,7 +462,7 @@ funcgoto(struct func *f, char *name) struct gotolabel *g; struct mapkey key; - mapstrkey(&key, name); + mapkey(&key, name, strlen(name)); entry = mapput(f->gotos, &key); g = *entry; if (!g) { diff --git a/scope.c b/scope.c @@ -70,7 +70,7 @@ scopegetdecl(struct scope *s, const char *name, bool recurse) struct decl *d; struct mapkey k; - mapstrkey(&k, name); + mapkey(&k, name, strlen(name)); do { d = s->decls ? mapget(s->decls, &k) : NULL; s = s->parent; @@ -85,7 +85,7 @@ scopegettag(struct scope *s, const char *name, bool recurse) struct type *t; struct mapkey k; - mapstrkey(&k, name); + mapkey(&k, name, strlen(name)); do { t = s->tags ? mapget(s->tags, &k) : NULL; s = s->parent; @@ -101,7 +101,7 @@ scopeputdecl(struct scope *s, const char *name, struct decl *d) if (!s->decls) s->decls = mkmap(32); - mapstrkey(&k, name); + mapkey(&k, name, strlen(name)); *mapput(s->decls, &k) = d; } @@ -112,6 +112,6 @@ scopeputtag(struct scope *s, const char *name, struct type *t) if (!s->tags) s->tags = mkmap(32); - mapstrkey(&k, name); + mapkey(&k, name, strlen(name)); *mapput(s->tags, &k) = t; }