From 19737494b9f67f935acd5ec141c5137b8d20c3f3 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 5 Dec 2013 12:53:31 +0000 Subject: array.c: prefer lhs elements * array.c (rb_ary_or): lhs elements are prefered, so should not replace with rhs elements. * test/ruby/test_array.rb (test_OR_in_order): import the test failed by r43969 from rubyspec/core/array/union_spec.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ array.c | 18 +++++++++++++++++- test/ruby/test_array.rb | 12 ++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index be5dda2a33..b5cc46169e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Dec 5 21:53:29 2013 Nobuyoshi Nakada + + * array.c (rb_ary_or): lhs elements are prefered, so should not + replace with rhs elements. + + * test/ruby/test_array.rb (test_OR_in_order): import the test failed + by r43969 from rubyspec/core/array/union_spec.rb. + Thu Dec 5 21:05:42 2013 Koichi Sasada * gc.c (gc_info_decode): fix to avoid syntax error on VS2012. diff --git a/array.c b/array.c index 39144b25f4..9668f17797 100644 --- a/array.c +++ b/array.c @@ -4025,6 +4025,14 @@ rb_ary_and(VALUE ary1, VALUE ary2) return ary3; } +static int +ary_hash_orset(st_data_t *key, st_data_t *value, st_data_t arg, int existing) +{ + if (existing) return ST_STOP; + *key = *value = (VALUE)arg; + return ST_CONTINUE; +} + /* * call-seq: * ary | other_ary -> new_ary @@ -4043,9 +4051,17 @@ static VALUE rb_ary_or(VALUE ary1, VALUE ary2) { VALUE hash, ary3; + long i; ary2 = to_ary(ary2); - hash = ary_add_hash(ary_make_hash(ary1), ary2); + hash = ary_make_hash(ary1); + + for (i=0; i