aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-18 14:03:20 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-18 14:03:20 +0100
commit07597cd35dfbdc7597d3b2b8ecf797016a996576 (patch)
treeaeeb5b2a2087c9e18efcd51c3915992ecf2e2be9 /miscutils
parentef271da33f1423b3f14aab6448c3001132cd128e (diff)
downloadbusybox-07597cd35dfbdc7597d3b2b8ecf797016a996576.tar.gz
bc: optimize zbc_lex_string()
function old new delta zbc_lex_next 2359 2353 -6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c19
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)
static BC_STATUS zbc_lex_string(BcLex *l)
{
- size_t len, nls = 0, i = l->i;
- char c;
+ size_t len, nls, i;
l->t.t = BC_LEX_STR;
- for (c = l->buf[i]; c != '\0' && c != '"'; c = l->buf[++i])
+ nls = 0;
+ i = l->i;
+ for (;;) {
+ char c = l->buf[i];
+ if (c == '\0') {
+ l->i = i;
+ RETURN_STATUS(bc_error("string end could not be found"));
+ }
+ if (c == '"')
+ break;
nls += (c == '\n');
-
- if (c == '\0') {
- l->i = i;
- RETURN_STATUS(bc_error("string end could not be found"));
+ i++;
}
len = i - l->i;