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

ruby-changes:51470

From: nobu <ko1@a...>
Date: Sun, 17 Jun 2018 11:41:29 +0900 (JST)
Subject: [ruby-changes:51470] nobu:r63680 (trunk): share Float 0

nobu	2018-06-17 11:41:26 +0900 (Sun, 17 Jun 2018)

  New Revision: 63680

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

  Log:
    share Float 0
    
    * complex.c (RFLOAT_0): share the 0.0 object on non-flonum
      platforms.

  Modified files:
    trunk/complex.c
Index: complex.c
===================================================================
--- complex.c	(revision 63679)
+++ complex.c	(revision 63680)
@@ -20,7 +20,11 @@ https://github.com/ruby/ruby/blob/trunk/complex.c#L20
 #define ZERO INT2FIX(0)
 #define ONE INT2FIX(1)
 #define TWO INT2FIX(2)
+#if USE_FLONUM
 #define RFLOAT_0 DBL2NUM(0)
+#else
+static VALUE RFLOAT_0;
+#endif
 #if defined(HAVE_SIGNBIT) && defined(__GNUC__) && defined(__sun) && \
     !defined(signbit)
 extern int signbit(double);
@@ -2271,6 +2275,10 @@ Init_Complex(void) https://github.com/ruby/ruby/blob/trunk/complex.c#L2275
     rb_define_const(rb_cComplex, "I",
 		    f_complex_new_bang2(rb_cComplex, ZERO, ONE));
 
+#if !USE_FLONUM
+    rb_gc_register_mark_object(RFLOAT_0 = DBL2NUM(0.0));
+#endif
+
     rb_provide("complex.so");	/* for backward compatibility */
 }
 

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

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