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

ruby-changes:34680

From: ko1 <ko1@a...>
Date: Wed, 9 Jul 2014 14:01:04 +0900 (JST)
Subject: [ruby-changes:34680] ko1:r46763 (trunk): * parse.y (symbols_i): delete garbage symbols for Symbol.all_symbols.

ko1	2014-07-09 14:00:53 +0900 (Wed, 09 Jul 2014)

  New Revision: 46763

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

  Log:
    * parse.y (symbols_i): delete garbage symbols for Symbol.all_symbols.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46762)
+++ ChangeLog	(revision 46763)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul  9 12:21:55 2014  Koichi Sasada  <ko1@a...>
+
+	* parse.y (symbols_i): delete garbage symbols for Symbol.all_symbols.
+
 Wed Jul  9 05:49:08 2014  Eric Wong  <e@8...>
 
 	* thread_pthread.h (struct rb_global_vm_lock_struct):
Index: parse.y
===================================================================
--- parse.y	(revision 46762)
+++ parse.y	(revision 46763)
@@ -10891,11 +10891,18 @@ static int https://github.com/ruby/ruby/blob/trunk/parse.y#L10891
 symbols_i(VALUE key, ID value, VALUE ary)
 {
     VALUE sym = ID2SYM(value);
-    if (ID_DYNAMIC_SYM_P(value)) {
-	sym = dsymbol_check(sym);
+
+    if (DYNAMIC_SYM_P(sym) && !SYMBOL_PINNED_P(sym) && rb_objspace_garbage_object_p(sym)) {
+	st_data_t sym_data = (st_data_t)sym;
+	st_delete(global_symbols.id_str, &sym_data, NULL);
+	RSYMBOL(sym)->fstr = 0;
+	return ST_DELETE;
+    }
+    else {
+	rb_ary_push(ary, sym);
+	return ST_CONTINUE;
     }
-    rb_ary_push(ary, sym);
-    return ST_CONTINUE;
+
 }
 
 /*
@@ -10918,7 +10925,6 @@ VALUE https://github.com/ruby/ruby/blob/trunk/parse.y#L10925
 rb_sym_all_symbols(void)
 {
     VALUE ary = rb_ary_new2(global_symbols.str_id->num_entries);
-
     st_foreach(global_symbols.str_id, symbols_i, ary);
     return ary;
 }

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

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