summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-07-28 00:30:25 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-07-28 00:30:25 -0700
commit0f0806c0aca034baacc975cf72130fc805f16232 (patch)
tree4a856d0b67796ef50f1de6ebabc5346f26647199
parentd0b49b2d85ba30207964ec8bfc99d4b7fb6e1328 (diff)
downloadtxr-0f0806c0aca034baacc975cf72130fc805f16232.tar.gz
txr-0f0806c0aca034baacc975cf72130fc805f16232.tar.bz2
txr-0f0806c0aca034baacc975cf72130fc805f16232.zip
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.
-rw-r--r--lib.c18
1 files changed, 13 insertions, 5 deletions
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)