summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-17 09:29:36 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-17 09:29:36 +0000
commit4c97b921f2f6d71d7a3f2c0b2c0c089b15686973 (patch)
tree7c0bd6b3abad22d25c3014052fd72a58ea07be51 /array.c
parent693efbb71035dede6459e0e5b73a5acdf38e5d90 (diff)
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/array.c b/array.c
index d88c333..157ac16 100644
--- a/array.c
+++ b/array.c
@@ -1242,22 +1242,13 @@ ary_flatten_bang(ary)
int mod = 0;
ary_modify(ary);
- for (;;) {
- int lmod = 0;
-
- for (i=0; i<RARRAY(ary)->len; i++) {
- if (TYPE(RARRAY(ary)->ptr[i]) == T_ARRAY) {
- VALUE ary2 = RARRAY(ary)->ptr[i];
-
- ary_replace(ary, i, RARRAY(ary2)->len, ary2);
- i += RARRAY(ary2)->len - 1;
- lmod++;
- }
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ VALUE ary2 = RARRAY(ary)->ptr[i];
+ if (TYPE(ary2) == T_ARRAY) {
+ ary_replace(ary, i--, 1, ary2);
+ mod = 1;
}
- if (lmod == 0) break;
- mod = lmod;
}
-
if (mod == 0) return Qnil;
return ary;
}