diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-05-30 18:43:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-05-30 18:43:15 -0700 |
commit | b2a3bbde854cb1b46ff84e6cf9f8219c727d42c4 (patch) | |
tree | 4abdf3adda4f6245d655e9cef81da7bec81a3b3b /parser.l | |
parent | 9bd308f89d9aaf75a05f9545e220b44420a697b7 (diff) | |
download | txr-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.l | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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; } |