ruby-changes:32360
From: nobu <ko1@a...>
Date: Thu, 26 Dec 2013 14:28:36 +0900 (JST)
Subject: [ruby-changes:32360] nobu:r44439 (trunk): hash.c: remove dead code
nobu 2013-12-26 14:28:24 +0900 (Thu, 26 Dec 2013) New Revision: 44439 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44439 Log: hash.c: remove dead code * hash.c (rb_hash_reject): remove dead code for the deprecated behavior. Modified files: trunk/hash.c trunk/test/ruby/test_hash.rb Index: hash.c =================================================================== --- hash.c (revision 44438) +++ hash.c (revision 44439) @@ -31,7 +31,6 @@ https://github.com/ruby/ruby/blob/trunk/hash.c#L31 ((klass = has_extra_methods(rb_obj_class(hash))) != 0) || \ FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \ !NIL_P(RHASH_IFNONE(hash))) -#define HASH_REJECT_COPY_EXTRA_STATES 0 static VALUE has_extra_methods(VALUE klass) @@ -291,7 +290,7 @@ rb_hash_new(void) https://github.com/ruby/ruby/blob/trunk/hash.c#L290 return hash_alloc(rb_cHash); } -static VALUE +static inline VALUE rb_hash_dup_empty(VALUE hash) { NEWOBJ_OF(ret, struct RHash, @@ -1146,34 +1145,10 @@ rb_hash_reject(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L1145 if (RTEST(ruby_verbose)) { VALUE klass; if (HAS_EXTRA_STATES(hash, klass)) { -#if HASH_REJECT_COPY_EXTRA_STATES - rb_warn("copying extra states: %+"PRIsVALUE, hash); - rb_warn("following states will not be copied in the future version:"); - if (klass) { - rb_warn(" subclass: %+"PRIsVALUE, klass); - } - if (FL_TEST(hash, FL_EXIVAR)) { - rb_warn(" instance variables: %+"PRIsVALUE, - rb_obj_instance_variables(hash)); - } - if (FL_TEST(hash, FL_TAINT)) { - rb_warn(" taintedness"); - } - if (FL_TEST(hash, HASH_PROC_DEFAULT)) { - rb_warn(" default proc: %+"PRIsVALUE, RHASH_IFNONE(hash)); - } - else if (!NIL_P(RHASH_IFNONE(hash))) - rb_warn(" default value: %+"PRIsVALUE, RHASH_IFNONE(hash)); -#else rb_warn("extra states are no longer copied: %+"PRIsVALUE, hash); -#endif } } -#if HASH_REJECT_COPY_EXTRA_STATES - result = rb_hash_dup_empty(hash); -#else result = rb_hash_new(); -#endif if (!RHASH_EMPTY_P(hash)) { rb_hash_foreach(hash, reject_i, result); } Index: test/ruby/test_hash.rb =================================================================== --- test/ruby/test_hash.rb (revision 44438) +++ test/ruby/test_hash.rb (revision 44439) @@ -558,18 +558,6 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L558 assert_equal(h3, h.reject {|k,v| v }) assert_equal(base, h) - unless RUBY_VERSION > "2.1.0" - if @cls == Hash - assert_empty(EnvUtil.verbose_warning {h.reject {false}}) - bug9275 = '[ruby-core:59254] [Bug #9275]' - c = Class.new(Hash) - assert_empty(EnvUtil.verbose_warning {c.new.reject {false}}, bug9275) - else - assert_match(/extra states/, EnvUtil.verbose_warning {h.reject {false}}) - end - return - end - h.instance_variable_set(:@foo, :foo) h.default = 42 h.taint -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/