mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1758 from ksss/array-out-while
move check condition to outside in while block
This commit is contained in:
+4
-6
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user