1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_or): use rb_hash_keys().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
glass 2013-10-10 14:02:52 +00:00
parent 840cd22d85
commit 2423e3f350
2 changed files with 5 additions and 14 deletions

View file

@ -1,3 +1,7 @@
Thu Oct 10 23:01:16 2013 Masaki Matsushita <glass.saga@gmail.com>
* array.c (rb_ary_or): use rb_hash_keys().
Thu Oct 10 21:36:16 2013 Masaki Matsushita <glass.saga@gmail.com>
* array.c (rb_ary_compact_bang): use ary_resize_smaller().

15
array.c
View file

@ -4004,21 +4004,8 @@ rb_ary_or(VALUE ary1, VALUE ary2)
long i;
ary2 = to_ary(ary2);
ary3 = rb_ary_new2(RARRAY_LEN(ary1)+RARRAY_LEN(ary2));
hash = ary_add_hash(ary_make_hash(ary1), ary2);
for (i=0; i<RARRAY_LEN(ary1); i++) {
vv = (st_data_t)(v = rb_ary_elt(ary1, i));
if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_push(ary3, v);
}
}
for (i=0; i<RARRAY_LEN(ary2); i++) {
vv = (st_data_t)(v = rb_ary_elt(ary2, i));
if (st_delete(rb_hash_tbl_raw(hash), &vv, 0)) {
rb_ary_push(ary3, v);
}
}
ary3 = rb_hash_keys(hash);
ary_recycle_hash(hash);
return ary3;
}