diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 14:03:20 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-18 14:03:20 +0100 |
commit | 07597cd35dfbdc7597d3b2b8ecf797016a996576 (patch) | |
tree | aeeb5b2a2087c9e18efcd51c3915992ecf2e2be9 | |
parent | ef271da33f1423b3f14aab6448c3001132cd128e (diff) | |
download | busybox-w32-07597cd35dfbdc7597d3b2b8ecf797016a996576.tar.gz busybox-w32-07597cd35dfbdc7597d3b2b8ecf797016a996576.tar.bz2 busybox-w32-07597cd35dfbdc7597d3b2b8ecf797016a996576.zip |
bc: optimize zbc_lex_string()
function old new delta
zbc_lex_next 2359 2353 -6
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/bc.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 5d969c9d0..be198a5fb 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -2986,17 +2986,22 @@ static BC_STATUS zbc_lex_identifier(BcLex *l) | |||
2986 | 2986 | ||
2987 | static BC_STATUS zbc_lex_string(BcLex *l) | 2987 | static BC_STATUS zbc_lex_string(BcLex *l) |
2988 | { | 2988 | { |
2989 | size_t len, nls = 0, i = l->i; | 2989 | size_t len, nls, i; |
2990 | char c; | ||
2991 | 2990 | ||
2992 | l->t.t = BC_LEX_STR; | 2991 | l->t.t = BC_LEX_STR; |
2993 | 2992 | ||
2994 | for (c = l->buf[i]; c != '\0' && c != '"'; c = l->buf[++i]) | 2993 | nls = 0; |
2994 | i = l->i; | ||
2995 | for (;;) { | ||
2996 | char c = l->buf[i]; | ||
2997 | if (c == '\0') { | ||
2998 | l->i = i; | ||
2999 | RETURN_STATUS(bc_error("string end could not be found")); | ||
3000 | } | ||
3001 | if (c == '"') | ||
3002 | break; | ||
2995 | nls += (c == '\n'); | 3003 | nls += (c == '\n'); |
2996 | 3004 | i++; | |
2997 | if (c == '\0') { | ||
2998 | l->i = i; | ||
2999 | RETURN_STATUS(bc_error("string end could not be found")); | ||
3000 | } | 3005 | } |
3001 | 3006 | ||
3002 | len = i - l->i; | 3007 | len = i - l->i; |