From 640a62ea716e05601089e8de6d463af6fd295d31 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 7 May 2008 09:18:06 +0000 Subject: [PATCH] * string.c (sym_to_i): remove obsolete method. preparation for symbol GC. * numeric.c (fix_to_sym): ditto. * numeric.c (fix_id2name): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 ++++++++ numeric.c | 49 ---------------------------------------- test/ruby/test_fixnum.rb | 7 ------ 3 files changed, 9 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index a50a647f87..a2fd07fb1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed May 7 18:02:01 2008 Yukihiro Matsumoto + + * string.c (sym_to_i): remove obsolete method. preparation for + symbol GC. + + * numeric.c (fix_to_sym): ditto. + + * numeric.c (fix_id2name): ditto. + Wed May 7 17:43:22 2008 Nobuyoshi Nakada * io.c (io_puts_ary): check recursion first. [ruby-dev:34580] diff --git a/numeric.c b/numeric.c index cc2f3f2059..ed8b3ff6b7 100644 --- a/numeric.c +++ b/numeric.c @@ -2850,52 +2850,6 @@ fix_abs(VALUE fix) return LONG2NUM(i); } -/* - * call-seq: - * fix.id2name -> string or nil - * - * Returns the name of the object whose symbol id is fix. If - * there is no symbol in the symbol table with this value, returns - * nil. id2name has nothing to do with the - * Object.id method. See also Fixnum#to_sym, - * String#intern, and class Symbol. - * - * symbol = :@inst_var #=> :@inst_var - * id = symbol.to_i #=> 9818 - * id.id2name #=> "@inst_var" - */ - -static VALUE -fix_id2name(VALUE fix) -{ - VALUE name = rb_id2str(FIX2UINT(fix)); - if (name) return rb_str_dup(name); - return Qnil; -} - - -/* - * call-seq: - * fix.to_sym -> aSymbol - * - * Returns the symbol whose integer value is fix. See also - * Fixnum#id2name. - * - * fred = :fred.to_i - * fred.id2name #=> "fred" - * fred.to_sym #=> :fred - */ - -static VALUE -fix_to_sym(VALUE fix) -{ - ID id = FIX2UINT(fix); - - if (rb_id2name(id)) { - return ID2SYM(id); - } - return Qnil; -} /* @@ -3205,9 +3159,6 @@ Init_Numeric(void) rb_define_method(rb_cFixnum, "to_s", fix_to_s, -1); - rb_define_method(rb_cFixnum, "id2name", fix_id2name, 0); - rb_define_method(rb_cFixnum, "to_sym", fix_to_sym, 0); - rb_define_method(rb_cFixnum, "-@", fix_uminus, 0); rb_define_method(rb_cFixnum, "+", fix_plus, 1); rb_define_method(rb_cFixnum, "-", fix_minus, 1); diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb index e0d2b18b44..43737d60b0 100644 --- a/test/ruby/test_fixnum.rb +++ b/test/ruby/test_fixnum.rb @@ -238,11 +238,4 @@ class TestFixnum < Test::Unit::TestCase assert(!(1.send(:<=, 0.0))) assert_raise(ArgumentError) { 1.send(:<=, nil) } end - - def test_id2name - assert_equal("foo", :foo.to_i.id2name) - assert_nil(0.id2name) - assert_equal(:foo, :foo.to_i.to_sym) - assert_nil(0.to_sym) - end end