From 5b95abb249604e7df9be1d63b1f3dc85b8f5990b Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 13 Aug 2022 11:04:44 +0200 Subject: set more --- src/util.cff | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/util.cff') diff --git a/src/util.cff b/src/util.cff index 70c80b4..9bb5db9 100644 --- a/src/util.cff +++ b/src/util.cff @@ -81,8 +81,10 @@ extern fn fatal(P *Parser, loc Loc, fmt *const u8, ...) void { extern fn internstr(s *const u8) *const u8 { static set Set<*const u8, struct { fn hash(s *const u8) u32 { return fnv1a_s(FNV1A_INI, s); } - fn eq(a *const u8, b *const u8) bool { return streq(a, b); } - fn dup(s *const u8) *const u8 { return as(*const u8)xstrdup(s); } + fn eq(a *const u8, b *const u8) bool { + return a != #null and b != #null and streq(a, b); + } + fn dup(s *const u8) *const u8 { return xstrdup(s); } }> = {}; return *set->intern(s); } -- cgit v1.2.3