From 2c7e5a527d2b9d11f1b0dfc0555d0f93bf7745af Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 31 Aug 2016 10:02:49 -0400 Subject: [PATCH] hoist unquoted case to top of the loop --- src/lib/token.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/lib/token.c b/src/lib/token.c index b7f5040..85e7080 100644 --- a/src/lib/token.c +++ b/src/lib/token.c @@ -231,6 +231,33 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, s = buf; while (*p && buflen-- > 1) { + /* + * We're looking for strings. Stop on spaces, or + * (if given a token list), on a token, or on a + * comma. + */ + if (!quote) { + if (isspace((int) *p)) { + break; + } + + if (tok) { + for (t = tokenlist; t->name; t++) { + if (TOKEN_MATCH(p, t->name)) { + *s++ = 0; + goto done; + } + } + } + if (*p == ',') break; + + /* + * Copy the character over. + */ + *s++ = *p++; + continue; + } + if (unescape && quote && (*p == '\\')) { p++; @@ -283,27 +310,6 @@ static FR_TOKEN getthing(char const **ptr, char *buf, int buflen, bool tok, p++; break; } - - /* - * We're looking for strings. Stop on spaces, or - * (if given a token list), on a token, or on a - * comma. - */ - if (!quote) { - if (isspace((int) *p)) { - break; - } - - if (tok) { - for (t = tokenlist; t->name; t++) { - if (TOKEN_MATCH(p, t->name)) { - *s++ = 0; - goto done; - } - } - } - if (*p == ',') break; - } *s++ = *p++; } -- 2.1.4