[git commit] bc: optimize bc_vec_concat()
Denys Vlasenko
vda.linux at googlemail.com
Mon Dec 10 14:12:58 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=8b4cf0dbb08a8a526045051b442e45cb2359b224
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
bc_vec_concat 71 66 -5
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/bc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/miscutils/bc.c b/miscutils/bc.c
index afd5c8d0e..71022569e 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -1165,13 +1165,14 @@ static void bc_vec_string(BcVec *v, size_t len, const char *str)
static void bc_vec_concat(BcVec *v, const char *str)
{
- size_t len;
+ size_t len, slen;
if (v->len == 0) bc_vec_pushZeroByte(v);
- len = v->len + strlen(str);
+ slen = strlen(str);
+ len = v->len + slen;
- if (v->cap < len) bc_vec_grow(v, len - v->len);
+ if (v->cap < len) bc_vec_grow(v, slen);
strcpy(v->v + v->len - 1, str);
v->len = len;
More information about the busybox-cvs
mailing list