From 0f0806c0aca034baacc975cf72130fc805f16232 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 28 Jul 2022 00:30:25 -0700 Subject: stringp: rewrite. * lib.c (stringp): Examine tag and then type separately, rather than using the canned type function. This leads to slightly nicer code, shorter by a couple of instructions. --- lib.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 94e462ba..b6b94ebb 100644 --- a/lib.c +++ b/lib.c @@ -5093,14 +5093,22 @@ val string_get_code(val str) val stringp(val str) { - switch (type(str)) { - case LIT: - case STR: - case LSTR: + if (str) switch (tag(str)) { + case TAG_LIT: return t; + case TAG_PTR: + switch (str->t.type) { + case STR: + case LSTR: + return t; + default: + break; + } + /* fallthrough */ default: - return nil; + break; } + return nil; } val lazy_stringp(val str) -- cgit v1.2.3