[前][次][番号順一覧][スレッド一覧]

ruby-changes:42094

From: mrkn <ko1@a...>
Date: Fri, 18 Mar 2016 10:22:45 +0900 (JST)
Subject: [ruby-changes:42094] mrkn:r54168 (trunk): * bignum.c (rb_big_hash): make it public function to be available in

mrkn	2016-03-18 10:22:38 +0900 (Fri, 18 Mar 2016)

  New Revision: 54168

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54168

  Log:
    * bignum.c (rb_big_hash): make it public function to be available in
      other source files, and remove documentation comment for Bignum#hash.
    
    * bignum.c (Bignum#hash): remove its definition because it is unified
      with Object#hash.
    
    * include/ruby/intern.h (rb_big_hash): add a prototype declaration.
    
    * hash.c (any_hash): treat Bignum values directly.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
    trunk/hash.c
    trunk/include/ruby/intern.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54167)
+++ ChangeLog	(revision 54168)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Mar 18 10:17:00 2016  Kenta Murata  <mrkn@m...>
+
+	* bignum.c (rb_big_hash): make it public function to be available in
+	  other source files, and remove documentation comment for Bignum#hash.
+
+	* bignum.c (Bignum#hash): remove its definition because it is unified
+	  with Object#hash.
+
+	* include/ruby/intern.h (rb_big_hash): add a prototype declaration.
+
+	* hash.c (any_hash): treat Bignum values directly.
+
 Fri Mar 18 02:35:12 2016  Naotoshi Seo  <sonots@g...>
 
 	* lib/time.rb (parse, strptime): Fix Time.parse/strptime does not
Index: hash.c
===================================================================
--- hash.c	(revision 54167)
+++ hash.c	(revision 54168)
@@ -169,6 +169,10 @@ any_hash(VALUE a, st_index_t (*other_fun https://github.com/ruby/ruby/blob/trunk/hash.c#L169
     else if (BUILTIN_TYPE(a) == T_SYMBOL) {
 	hnum = RSYMBOL(a)->hashval;
     }
+    else if (BUILTIN_TYPE(a) == T_BIGNUM) {
+	hval = rb_big_hash(a);
+	hnum = FIX2LONG(hval);
+    }
     else if (BUILTIN_TYPE(a) == T_FLOAT) {
       flt:
 	hval = rb_dbl_hash(rb_float_value(a));
Index: bignum.c
===================================================================
--- bignum.c	(revision 54167)
+++ bignum.c	(revision 54168)
@@ -6837,16 +6837,7 @@ rb_big_aref(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6837
     return (xds[s1] & bit) ? INT2FIX(1) : INT2FIX(0);
 }
 
-/*
- * call-seq:
- *   big.hash   -> fixnum
- *
- * Compute a hash based on the value of _big_.
- *
- * See also Object#hash.
- */
-
-static VALUE
+VALUE
 rb_big_hash(VALUE x)
 {
     st_index_t hash;
@@ -7085,7 +7076,6 @@ Init_Bignum(void) https://github.com/ruby/ruby/blob/trunk/bignum.c#L7076
     rb_define_method(rb_cBignum, "<=", big_le, 1);
     rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
     rb_define_method(rb_cBignum, "eql?", rb_big_eql, 1);
-    rb_define_method(rb_cBignum, "hash", rb_big_hash, 0);
     rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0);
     rb_define_method(rb_cBignum, "abs", rb_big_abs, 0);
     rb_define_method(rb_cBignum, "magnitude", rb_big_abs, 0);
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 54167)
+++ include/ruby/intern.h	(revision 54168)
@@ -133,6 +133,7 @@ VALUE rb_big_lshift(VALUE, VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L133
 VALUE rb_big_rshift(VALUE, VALUE);
 VALUE rb_big_odd_p(VALUE);
 VALUE rb_big_even_p(VALUE);
+VALUE rb_big_hash(VALUE);
 
 /* For rb_integer_pack and rb_integer_unpack: */
 /* "MS" in MSWORD and MSBYTE means "most significant" */

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]