[git commit] bc: further zbc_vm_stdin() optimizations
Denys Vlasenko
vda.linux at googlemail.com
Thu Dec 13 16:36:41 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=7dc0a51286b7898fcc17033dce1f1856e78494b4
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
bc_vm_run 534 514 -20
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/bc.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 7ab320a4d..9c7e69fc1 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -7072,11 +7072,9 @@ static BC_STATUS zbc_vm_stdin(void)
else if (buf.v[0] == G.sbgn)
str += 1;
} else {
- size_t i;
- for (i = 0; i < len; ++i) {
- char c = string[i];
-
- if (i - 1 > len || string[i - 1] != '\\') {
+ while (*string) {
+ char c = *string;
+ if (string != buf.v && string[-1] != '\\') {
// checking applet type is cheaper than accessing sbgn/send
if (IS_DC) // dc: sbgn = send = '"'
str ^= (c == '"');
@@ -7087,16 +7085,15 @@ static BC_STATUS zbc_vm_stdin(void)
str += 1;
}
}
-
- if (c == '/' && !comment && string[i + 1] == '*') {
+ string++;
+ if (c == '/' && *string == '*') {
comment = true;
break;
}
- else if (c == '*' && comment && string[i + 1] == '/')
+ if (c == '*' && *string == '/')
comment = false;
}
-
- if (str || comment || string[len - 2] == '\\') {
+ if (str || comment || string[-2] == '\\') {
bc_vec_concat(&buffer, buf.v);
continue;
}
More information about the busybox-cvs
mailing list