summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-10-18 09:07:13 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-10-18 09:07:13 +0000
commitfd1fe9cf1d96e9b52478befa123836c73728e3e4 (patch)
tree69980dcadc4ce62190748ab4493aad303b4fd712 /array.c
parenta438c908aa512803d084d507a54a9968ac121352 (diff)
19991018
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/array.c b/array.c
index a982627937..f3bd553872 100644
--- a/array.c
+++ b/array.c
@@ -943,26 +943,19 @@ rb_ary_delete_at(ary, at)
VALUE ary;
VALUE at;
{
- long i1, i2, pos;
+ long i, pos = NUM2LONG(at), len = RARRAY(ary)->len;
VALUE del = Qnil;
+ rb_ary_modify(ary);
if (pos >= len) return Qnil;
if (pos < 0) pos += len;
if (pos < 0) return Qnil;
- rb_ary_modify(ary);
- pos = NUM2LONG(at);
- for (i1 = i2 = 0; i1 < RARRAY(ary)->len; i1++) {
- if (i1 == pos) {
- del = RARRAY(ary)->ptr[i1];
- continue;
- }
- if (i1 != i2) {
- RARRAY(ary)->ptr[i2] = RARRAY(ary)->ptr[i1];
- }
- i2++;
+ del = RARRAY(ary)->ptr[pos];
+ for (i = pos + 1; i < len; i++, pos++) {
+ RARRAY(ary)->ptr[pos] = RARRAY(ary)->ptr[i];
}
- RARRAY(ary)->len = i2;
+ RARRAY(ary)->len = pos;
return del;
}