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

ruby-changes:31497

From: nobu <ko1@a...>
Date: Fri, 8 Nov 2013 03:10:37 +0900 (JST)
Subject: [ruby-changes:31497] nobu:r43576 (trunk): gc.c: use switch for alternative BUILTIN_TYPE

nobu	2013-11-08 03:10:33 +0900 (Fri, 08 Nov 2013)

  New Revision: 43576

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

  Log:
    gc.c: use switch for alternative BUILTIN_TYPE
    
    * gc.c (rb_objspace_call_finalizer): BUILTIN_TYPE is alternative,
      T_DATA object (Thread, Mutex, Fiber) cannot be T_FILE.

  Modified files:
    trunk/gc.c
Index: gc.c
===================================================================
--- gc.c	(revision 43575)
+++ gc.c	(revision 43576)
@@ -2116,11 +2116,12 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/gc.c#L2116
     for (i = 0; i < heap_pages_used; i++) {
 	p = heap_pages_sorted[i]->start; pend = p + heap_pages_sorted[i]->limit;
 	while (p < pend) {
-	    if (BUILTIN_TYPE(p) == T_DATA &&
-		DATA_PTR(p) && RANY(p)->as.data.dfree &&
-		!rb_obj_is_thread((VALUE)p) &&
-		!rb_obj_is_mutex((VALUE)p) &&
-		!rb_obj_is_fiber((VALUE)p)) {
+	    switch (BUILTIN_TYPE(p)) {
+	      case T_DATA:
+		if (!DATA_PTR(p) || !RANY(p)->as.data.dfree) break;
+		if (rb_obj_is_thread((VALUE)p)) break;
+		if (rb_obj_is_mutex((VALUE)p)) break;
+		if (rb_obj_is_fiber((VALUE)p)) break;
 		p->as.free.flags = 0;
 		if (RTYPEDDATA_P(p)) {
 		    RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
@@ -2131,11 +2132,12 @@ rb_objspace_call_finalizer(rb_objspace_t https://github.com/ruby/ruby/blob/trunk/gc.c#L2132
 		else if (RANY(p)->as.data.dfree) {
 		    make_deferred(objspace, RANY(p));
 		}
-	    }
-	    else if (BUILTIN_TYPE(p) == T_FILE) {
+		break;
+	      case T_FILE:
 		if (RANY(p)->as.file.fptr) {
 		    make_io_deferred(objspace, RANY(p));
 		}
+		break;
 	    }
 	    p++;
 	}

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

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