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

ruby-changes:52278

From: normal <ko1@a...>
Date: Tue, 21 Aug 2018 06:34:48 +0900 (JST)
Subject: [ruby-changes:52278] normal:r64486 (trunk): thread*.c: avoid unnecessary initialization for list_for_each_safe

normal	2018-08-21 06:34:44 +0900 (Tue, 21 Aug 2018)

  New Revision: 64486

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

  Log:
    thread*.c: avoid unnecessary initialization for list_for_each_safe
    
    According to r52446, it is only necessary for the current item (@i),
    not the `@nxt` parameter for list_for_each_safe.

  Modified files:
    trunk/thread.c
    trunk/thread_sync.c
Index: thread.c
===================================================================
--- thread.c	(revision 64485)
+++ thread.c	(revision 64486)
@@ -2332,8 +2332,7 @@ int https://github.com/ruby/ruby/blob/trunk/thread.c#L2332
 rb_notify_fd_close(int fd, struct list_head *busy)
 {
     rb_vm_t *vm = GET_THREAD()->vm;
-    struct waiting_fd *wfd = 0;
-    struct waiting_fd *next = 0;
+    struct waiting_fd *wfd = 0, *next;
 
     list_for_each_safe(&vm->waiting_fds, wfd, next, wfd_node) {
 	if (wfd->fd == fd) {
Index: thread_sync.c
===================================================================
--- thread_sync.c	(revision 64485)
+++ thread_sync.c	(revision 64486)
@@ -15,7 +15,7 @@ struct sync_waiter { https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L15
 static int
 wakeup_one(struct list_head *head)
 {
-    struct sync_waiter *cur = 0, *next = 0;
+    struct sync_waiter *cur = 0, *next;
 
     list_for_each_safe(head, cur, next, node) {
 	list_del_init(&cur->node);
@@ -31,7 +31,7 @@ wakeup_one(struct list_head *head) https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L31
 static void
 wakeup_all(struct list_head *head)
 {
-    struct sync_waiter *cur = 0, *next = 0;
+    struct sync_waiter *cur = 0, *next;
 
     list_for_each_safe(head, cur, next, node) {
 	list_del_init(&cur->node);
@@ -347,7 +347,7 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L347
 	err = "Attempt to unlock a mutex which is locked by another thread";
     }
     else {
-	struct sync_waiter *cur = 0, *next = 0;
+	struct sync_waiter *cur = 0, *next;
 	rb_mutex_t **th_mutex = &th->keeping_mutexes;
 
 	mutex->th = 0;

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

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