summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-10 01:39:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-10 01:39:24 +0000
commit160055b47468d48dc0443bfbbeabf750bcfe8296 (patch)
tree49ff0eaefef57b5e29a37e7cb3515d77d8e9fae8 /array.c
parent5a0361f84c28d38747c066bda30ecf77483877f9 (diff)
* bignum.c (rb_big_mul0): multiply two numbers (x, y) without
normalizing the result. x should be a big number. [ruby-dev:26778] * bignum.c (rb_big_pow): use rb_big_mul0() instead of rb_big_mul(). * array.c (rb_ary_or, rb_ary_and, rb_ary_plus, rb_ary_diff): revert the change on 2005-08-03. Set operation on other item should have in separate methods. * parse.y (shadowing_lvar_gen): warn when arguments shadows external local variables. * parse.y (f_opt): optional arguments should not clobber external local variables. * parse.y (f_rest_arg): rest arguments should not clobber external local variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/array.c b/array.c
index 7250a70c5f..cdb64bf4d8 100644
--- a/array.c
+++ b/array.c
@@ -302,17 +302,6 @@ to_ary(ary)
}
static VALUE
-make_ary(ary)
- VALUE ary;
-{
- VALUE tmp = rb_check_array_type(ary);
- if (NIL_P(tmp)) {
- return rb_ary_new3(1, ary);
- }
- return tmp;
-}
-
-static VALUE
to_a(ary)
VALUE ary;
{
@@ -2355,16 +2344,10 @@ VALUE
rb_ary_plus(x, y)
VALUE x, y;
{
- VALUE tmp, z;
+ VALUE z;
long len;
- tmp = rb_check_array_type(y);
- if (NIL_P(tmp)) {
- z = rb_ary_dup(x);
- rb_ary_push(z, y);
- return z;
- }
- y = tmp;
+ y = to_ary(y);
len = RARRAY(x)->len + RARRAY(y)->len;
z = rb_ary_new2(len);
MEMCPY(RARRAY(z)->ptr, RARRAY(x)->ptr, VALUE, RARRAY(x)->len);
@@ -2711,10 +2694,10 @@ static VALUE
rb_ary_diff(ary1, ary2)
VALUE ary1, ary2;
{
- VALUE tmp, ary3, hash;
+ VALUE ary3, hash;
long i;
- hash = ary_make_hash(make_ary(ary2), 0);
+ hash = ary_make_hash(to_ary(ary2), 0);
ary3 = rb_ary_new();
for (i=0; i<RARRAY(ary1)->len; i++) {
@@ -2742,9 +2725,9 @@ rb_ary_and(ary1, ary2)
VALUE hash, ary3, v, vv;
long i;
- ary2 = make_ary(ary2);
+ ary2 = to_ary(ary2);
ary3 = rb_ary_new2(RARRAY(ary1)->len < RARRAY(ary2)->len ?
- RARRAY(ary1)->len : RARRAY(ary2)->len);
+ RARRAY(ary1)->len : RARRAY(ary2)->len);
hash = ary_make_hash(ary2, 0);
for (i=0; i<RARRAY(ary1)->len; i++) {
@@ -2776,7 +2759,7 @@ rb_ary_or(ary1, ary2)
VALUE v, vv;
long i;
- ary2 = make_ary(ary2);
+ ary2 = to_ary(ary2);
ary3 = rb_ary_new2(RARRAY(ary1)->len+RARRAY(ary2)->len);
hash = ary_make_hash(ary1, ary2);