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

ruby-changes:30635

From: nobu <ko1@a...>
Date: Wed, 28 Aug 2013 14:59:19 +0900 (JST)
Subject: [ruby-changes:30635] nobu:r42714 (trunk): thread_pthread.c: simplify

nobu	2013-08-28 14:59:13 +0900 (Wed, 28 Aug 2013)

  New Revision: 42714

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

  Log:
    thread_pthread.c: simplify
    
    * thread_pthread.c (register_cached_thread_and_wait): simplify and
      reduce branches.

  Modified files:
    trunk/thread_pthread.c
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 42713)
+++ thread_pthread.c	(revision 42714)
@@ -801,21 +801,14 @@ register_cached_thread_and_wait(void) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L801
 	native_cond_timedwait(&cond, &thread_cache_lock, &ts);
 
 	{
-	    struct cached_thread_entry *e = cached_thread_root;
-	    struct cached_thread_entry *prev = cached_thread_root;
+	    struct cached_thread_entry *e, **prev = &cached_thread_root;
 
-	    while (e) {
+	    while ((e = *prev) != 0) {
 		if (e == entry) {
-		    if (prev == cached_thread_root) {
-			cached_thread_root = e->next;
-		    }
-		    else {
-			prev->next = e->next;
-		    }
+		    *prev = e->next;
 		    break;
 		}
-		prev = e;
-		e = e->next;
+		prev = &e->next;
 	    }
 	}
 

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

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