ruby-changes:31891
From: glass <ko1@a...>
Date: Tue, 3 Dec 2013 14:13:27 +0900 (JST)
Subject: [ruby-changes:31891] glass:r43970 (trunk): * array.c (rb_ary_uniq_bang): remove duplicate code.
glass 2013-12-03 14:13:19 +0900 (Tue, 03 Dec 2013) New Revision: 43970 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43970 Log: * array.c (rb_ary_uniq_bang): remove duplicate code. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 43969) +++ array.c (revision 43970) @@ -4063,13 +4063,6 @@ rb_ary_or(VALUE ary1, VALUE ary2) https://github.com/ruby/ruby/blob/trunk/array.c#L4063 } static int -push_val(st_data_t key, st_data_t val, st_data_t ary) -{ - rb_ary_push((VALUE)ary, (VALUE)val); - return ST_CONTINUE; -} - -static int push_value(st_data_t key, st_data_t val, st_data_t ary) { rb_ary_push((VALUE)ary, (VALUE)val); @@ -4110,36 +4103,23 @@ rb_ary_uniq_bang(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L4103 rb_ary_modify_check(ary); if (RARRAY_LEN(ary) <= 1) return Qnil; - if (rb_block_given_p()) { + if (rb_block_given_p()) hash = ary_make_hash_by(ary); - hash_size = RHASH_SIZE(hash); - if (RARRAY_LEN(ary) == hash_size) { - return Qnil; - } - rb_ary_modify_check(ary); - ARY_SET_LEN(ary, 0); - if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) { - rb_ary_unshare(ary); - FL_SET_EMBED(ary); - } - ary_resize_capa(ary, hash_size); - st_foreach(rb_hash_tbl_raw(hash), push_value, ary); - } - else { + else hash = ary_make_hash(ary); - hash_size = RHASH_SIZE(hash); - if (RARRAY_LEN(ary) == hash_size) { - return Qnil; - } - rb_ary_modify_check(ary); - ARY_SET_LEN(ary, 0); - if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) { - rb_ary_unshare(ary); - FL_SET_EMBED(ary); - } - ary_resize_capa(ary, hash_size); - st_foreach(rb_hash_tbl_raw(hash), push_val, ary); + + hash_size = RHASH_SIZE(hash); + if (RARRAY_LEN(ary) == hash_size) { + return Qnil; + } + rb_ary_modify_check(ary); + ARY_SET_LEN(ary, 0); + if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) { + rb_ary_unshare(ary); + FL_SET_EMBED(ary); } + ary_resize_capa(ary, hash_size); + st_foreach(rb_hash_tbl_raw(hash), push_value, ary); ary_recycle_hash(hash); return ary; Index: ChangeLog =================================================================== --- ChangeLog (revision 43969) +++ ChangeLog (revision 43970) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Dec 3 14:05:49 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_uniq_bang): remove duplicate code. + Tue Dec 3 13:40:42 2013 Masaki Matsushita <glass.saga@g...> * array.c (ary_add_hash): set and return values because string keys -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/