bc: simplify bc_array_expand()
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 18 Dec 2018 19:10:48 +0000 (20:10 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 18 Dec 2018 19:10:48 +0000 (20:10 +0100)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c

index e62ca0f69cd0a0e3a4ed22f2fb8563bae05100e5..7ddae341ffe3698107ceed9664321f7388970960 100644 (file)
@@ -2547,17 +2547,19 @@ static void bc_array_init(BcVec *a, bool nums)
 
 static void bc_array_expand(BcVec *a, size_t len)
 {
-       BcResultData data;
-
-       if (a->size == sizeof(BcNum) && a->dtor == bc_num_free) {
+       if (a->dtor == bc_num_free
+        // && a->size == sizeof(BcNum) - always true
+       ) {
+               BcNum n;
                while (len > a->len) {
-                       bc_num_init_DEF_SIZE(&data.n);
-                       bc_vec_push(a, &data.n);
+                       bc_num_init_DEF_SIZE(&n);
+                       bc_vec_push(a, &n);
                }
        } else {
+               BcVec v;
                while (len > a->len) {
-                       bc_array_init(&data.v, true);
-                       bc_vec_push(a, &data.v);
+                       bc_array_init(&v, true);
+                       bc_vec_push(a, &v);
                }
        }
 }