From e9e7baf5bec50929acf2b79cdcd1af17ce0e9b3f Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 13 Feb 2024 14:24:31 +0100 Subject: More simplification --- src/c8asm/assembler.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/c8asm/assembler.c b/src/c8asm/assembler.c index b5c6f1b..6160397 100644 --- a/src/c8asm/assembler.c +++ b/src/c8asm/assembler.c @@ -58,25 +58,22 @@ getlabel(struct u8view sv) uint16_t getaddr(struct raw_addr a) { - if (a.label) { - struct label *lbl = getlabel(a.sv); - if (lbl) - return lbl->addr; - die_with_off(filename, a.sv.p - baseptr, E_LNEXISTS, U8_PRI_ARGS(a.sv)); - } - return a.val; + struct label *lbl; + if (!a.label) + return a.val; + if (lbl = getlabel(a.sv)) + return lbl->addr; + die_with_off(filename, a.sv.p - baseptr, E_LNEXISTS, U8_PRI_ARGS(a.sv)); } void pushlabel(struct labels *dst, struct label lbl) { - da_foreach (dst, stored) { - if (u8eq(stored->sv, lbl.sv)) { - die_with_off(filename, lbl.sv.p - baseptr, E_LEXISTS, - U8_PRI_ARGS(lbl.sv)); - } + struct label *found; + if (found = getlabel(lbl.sv)) { + die_with_off(filename, lbl.sv.p - baseptr, E_LEXISTS, + U8_PRI_ARGS(lbl.sv)); } - dapush(dst, lbl); } -- cgit v1.2.3