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

ruby-changes:42853

From: nobu <ko1@a...>
Date: Fri, 6 May 2016 14:33:20 +0900 (JST)
Subject: [ruby-changes:42853] nobu:r54927 (trunk): random.c: default seed mark

nobu	2016-05-06 15:29:56 +0900 (Fri, 06 May 2016)

  New Revision: 54927

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

  Log:
    random.c: default seed mark
    
    * random.c (Init_Random_default): since seed is marked by
      random_mark, no needs to mark itself as a global variable.
      allocate Random instance before making the seed value, to get
      rid of the potential risk of GC during the allocation.

  Modified files:
    trunk/random.c
Index: random.c
===================================================================
--- random.c	(revision 54926)
+++ random.c	(revision 54927)
@@ -1544,13 +1544,10 @@ Init_Random_default(void) https://github.com/ruby/ruby/blob/trunk/random.c#L1544
 {
     rb_random_t *r = &default_rand;
     struct MT *mt = &r->mt;
-    VALUE v;
+    VALUE v = TypedData_Wrap_Struct(rb_cRandom, &random_data_type, r);
 
-    r->seed = init_randomseed(mt);
-    rb_global_variable(&r->seed);
-
-    v = TypedData_Wrap_Struct(rb_cRandom, &random_data_type, r);
     rb_gc_register_mark_object(v);
+    r->seed = init_randomseed(mt);
 
     return v;
 }

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

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