diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-07-28 00:30:25 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-07-28 00:30:25 -0700 |
commit | 0f0806c0aca034baacc975cf72130fc805f16232 (patch) | |
tree | 4a856d0b67796ef50f1de6ebabc5346f26647199 | |
parent | d0b49b2d85ba30207964ec8bfc99d4b7fb6e1328 (diff) | |
download | txr-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.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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) |