diff options
author | Maria Matejka <mq@ucw.cz> | 2019-02-25 23:28:36 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-02-25 23:28:36 +0100 |
commit | 2915e711f77d68dff756babd19af8da1677c4549 (patch) | |
tree | 3fb2f8b5decbc9db40c5b9b00847dc49c0703f21 /conf/cf-lex.l | |
parent | 99911873a196975f5221aad89ae5eac42e1330e0 (diff) |
Custom number parser to speed up config parsing
The glibc's generic parser is slow due to its versatility. Specialized
parsers for base-10 and base-16 are much faster and we don't use other
bases.
Diffstat (limited to 'conf/cf-lex.l')
-rw-r--r-- | conf/cf-lex.l | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l index 45327cd9..593df9d6 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -168,7 +168,7 @@ WHITE [ \t] char *e; errno = 0; - l = strtoul(yytext, &e, 10); + l = bstrtoul(yytext, &e, 10); if (e && (*e != ':') || (errno == ERANGE) || (l >> 32)) cf_error("ASN out of range"); @@ -186,7 +186,7 @@ WHITE [ \t] } errno = 0; - l = strtoul(e+1, &e, 10); + l = bstrtoul(e+1, &e, 10); if (e && *e || (errno == ERANGE) || (l >> len2)) cf_error("Number out of range"); cf_lval.i64 |= l; @@ -213,13 +213,13 @@ WHITE [ \t] } errno = 0; - l = strtoul(yytext+2, &e, 10); + l = bstrtoul(yytext+2, &e, 10); if (e && (*e != ':') || (errno == ERANGE) || (l >> len1)) cf_error("ASN out of range"); cf_lval.i64 |= ((u64) l) << len2; errno = 0; - l = strtoul(e+1, &e, 10); + l = bstrtoul(e+1, &e, 10); if (e && *e || (errno == ERANGE) || (l >> len2)) cf_error("Number out of range"); cf_lval.i64 |= l; @@ -241,7 +241,7 @@ WHITE [ \t] cf_lval.i64 |= ((u64) ip4_to_u32(ip4)) << 16; errno = 0; - l = strtoul(e, &e, 10); + l = bstrtoul(e, &e, 10); if (e && *e || (errno == ERANGE) || (l >> 16)) cf_error("Number out of range"); cf_lval.i64 |= l; @@ -265,7 +265,7 @@ WHITE [ \t] char *e; unsigned long int l; errno = 0; - l = strtoul(yytext+2, &e, 16); + l = bstrtoul(yytext+2, &e, 16); if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l) cf_error("Number out of range"); cf_lval.i = l; @@ -276,7 +276,7 @@ WHITE [ \t] char *e; unsigned long int l; errno = 0; - l = strtoul(yytext, &e, 10); + l = bstrtoul(yytext, &e, 10); if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l) cf_error("Number out of range"); cf_lval.i = l; |