summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-05-30 18:43:15 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-05-30 18:43:15 -0700
commitb2a3bbde854cb1b46ff84e6cf9f8219c727d42c4 (patch)
tree4abdf3adda4f6245d655e9cef81da7bec81a3b3b /parser.l
parent9bd308f89d9aaf75a05f9545e220b44420a697b7 (diff)
downloadtxr-b2a3bbde854cb1b46ff84e6cf9f8219c727d42c4.tar.gz
txr-b2a3bbde854cb1b46ff84e6cf9f8219c727d42c4.tar.bz2
txr-b2a3bbde854cb1b46ff84e6cf9f8219c727d42c4.zip
parser: scan buflit characters faster.
* parser.l (BUFLIT): Instead of scanning a hexadecimal digit and using strol, we scan three separate cases, and do a very simple subtraction in each one. TXR Lisp .tlo files are full of large buffer literals, so this affects loading speed. * lex.yy.c.shipped: Regenerated.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l14
1 files changed, 12 insertions, 2 deletions
diff --git a/parser.l b/parser.l
index c889d759..02cf2a8a 100644
--- a/parser.l
+++ b/parser.l
@@ -1234,8 +1234,18 @@ NJPUNC [^(){},:\[\]"~*^ \t\r\n]
return LITCHAR;
}
-<BUFLIT>{HEX} {
- yylval->chr = strtol(yytext, 0, 16);
+<BUFLIT>[0-9] {
+ yylval->chr = yytext[0] - '0';
+ return LITCHAR;
+}
+
+<BUFLIT>[A-F] {
+ yylval->chr = yytext[0] - 'A' + 10;
+ return LITCHAR;
+}
+
+<BUFLIT>[a-f] {
+ yylval->chr = yytext[0] - 'a' + 10;
return LITCHAR;
}