1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2018-08-20 21:34:44 +00:00
parent 17e4aff277
commit 39c64117f6
2 changed files with 4 additions and 5 deletions

View file

@ -2332,8 +2332,7 @@ int
rb_notify_fd_close(int fd, struct list_head *busy) rb_notify_fd_close(int fd, struct list_head *busy)
{ {
rb_vm_t *vm = GET_THREAD()->vm; rb_vm_t *vm = GET_THREAD()->vm;
struct waiting_fd *wfd = 0; struct waiting_fd *wfd = 0, *next;
struct waiting_fd *next = 0;
list_for_each_safe(&vm->waiting_fds, wfd, next, wfd_node) { list_for_each_safe(&vm->waiting_fds, wfd, next, wfd_node) {
if (wfd->fd == fd) { if (wfd->fd == fd) {

View file

@ -15,7 +15,7 @@ struct sync_waiter {
static int static int
wakeup_one(struct list_head *head) 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_for_each_safe(head, cur, next, node) {
list_del_init(&cur->node); list_del_init(&cur->node);
@ -31,7 +31,7 @@ wakeup_one(struct list_head *head)
static void static void
wakeup_all(struct list_head *head) 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_for_each_safe(head, cur, next, node) {
list_del_init(&cur->node); list_del_init(&cur->node);
@ -347,7 +347,7 @@ rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th)
err = "Attempt to unlock a mutex which is locked by another thread"; err = "Attempt to unlock a mutex which is locked by another thread";
} }
else { else {
struct sync_waiter *cur = 0, *next = 0; struct sync_waiter *cur = 0, *next;
rb_mutex_t **th_mutex = &th->keeping_mutexes; rb_mutex_t **th_mutex = &th->keeping_mutexes;
mutex->th = 0; mutex->th = 0;