Merge pull request #1758 from ksss/array-out-while

move check condition to outside in while block
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-02-28 00:51:33 +09:00
+4 -6
View File
@@ -185,13 +185,11 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
if (capa == 0) {
capa = ARY_DEFAULT_LEN;
}
while (capa < len) {
if (capa == 0) {
capa = ARY_DEFAULT_LEN;
}
else {
capa *= 2;
}
capa *= 2;
}
if (capa > ARY_MAX_SIZE) capa = ARY_MAX_SIZE; /* len <= capa <= ARY_MAX_SIZE */