parseaut: convert short numbers without strtoul()

* spot/parseaut/scanaut.ll: One or two digits numbers can be safely
converted to integer without risking overflow, so do that without
calling strtoul().  This simple change halves the number of calls
to strtoul() on the example automaton of issue #476.
This commit is contained in:
Alexandre Duret-Lutz 2021-09-15 17:21:04 +02:00
parent 4c94e14f86
commit 42ff02585b

View file

@ -189,6 +189,12 @@ identifier [[:alpha:]_][[:alnum:]_.-]*
yylval->str = new std::string(yytext + 1, yyleng - 1);
return token::ANAME;
}
/* Handle short numbers without going through parse_int() for efficiency. */
[0-9] yylval->num = *yytext - '0'; return token::INT;
[0-9][0-9] {
yylval->num = (yytext[0] * 10) + yytext[1] - '0' * 11;
return token::INT;
}
[0-9]+ parse_int(); return token::INT;
}
@ -204,6 +210,12 @@ identifier [[:alpha:]_][[:alnum:]_.-]*
"Acceptance-Pairs:" return token::ACCPAIRS;
"Acc-Sig:" return token::ACCSIG;
"---" return token::ENDOFHEADER;
/* Handle short numbers without going through parse_int() for efficiency. */
[0-9] yylval->num = *yytext - '0'; return token::INT;
[0-9][0-9] {
yylval->num = (yytext[0] * 10) + yytext[1] - '0' * 11;
return token::INT;
}
[0-9]+ parse_int(); return token::INT;
/* The start of any automaton is the end of this one.
We do not try to detect LBTT automata, as that would