diff --git a/WHATS_NEW b/WHATS_NEW index d60f22668..42d74914b 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.85 - =================================== + Optimise _get_token() and _eat_space(). Add _lv_postorder_vg() to improve efficiency for all LVs in VG. Use hash tables to speedup string search in validate_vg(). Refactor allocation of VG structure, add alloc_vg(). diff --git a/lib/config/config.c b/lib/config/config.c index e6e97cfe2..9fb2bf61d 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -822,18 +822,20 @@ static void _get_token(struct parser *p, int tok_prev) case '+': case '-': if (values_allowed) { - te++; - while ((te != p->fe) && (*te)) { - if (*te == '.') { - if (p->t == TOK_FLOAT) - break; - p->t = TOK_FLOAT; - } else if (!isdigit((int) *te)) + while (++te != p->fe) { + if (!isdigit((int) *te)) { + if (*te == '.') { + if (p->t != TOK_FLOAT) { + p->t = TOK_FLOAT; + continue; + } + } break; - te++; + } } break; } + /* fall through */ default: p->t = TOK_IDENTIFIER; @@ -850,22 +852,20 @@ static void _get_token(struct parser *p, int tok_prev) static void _eat_space(struct parser *p) { - while ((p->tb != p->fe) && (*p->tb)) { + while (p->tb != p->fe) { if (*p->te == '#') - while ((p->te != p->fe) && (*p->te) && (*p->te != '\n')) - p->te++; + while ((p->te != p->fe) && (*p->te != '\n') && (*p->te)) + ++p->te; - else if (isspace(*p->te)) { - while ((p->te != p->fe) && (*p->te) && isspace(*p->te)) { - if (*p->te == '\n') - p->line++; - p->te++; - } + else if (!isspace(*p->te)) + break; + + while ((p->te != p->fe) && isspace(*p->te)) { + if (*p->te == '\n') + ++p->line; + ++p->te; } - else - return; - p->tb = p->te; } }