diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-31 04:02:18 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-31 04:02:18 +0000 |
commit | 80d74ea732b31f0a5eba5e2569f832388a95c0f4 (patch) | |
tree | 4b9bda6c87a51fdda7ea2103518c83bde52ca277 /io.c | |
parent | e97cc464605a5d6c9417bb449f27b36ceeb3e840 (diff) | |
download | bundler-80d74ea732b31f0a5eba5e2569f832388a95c0f4.tar.gz |
io.c: simplified pipe_del_fptr
* io.c (pipe_del_fptr): merged code for the case fptr is first to
the loop for the rest.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -6150,23 +6150,16 @@ pipe_add_fptr(rb_io_t *fptr) static void pipe_del_fptr(rb_io_t *fptr) { - struct pipe_list *list = pipe_list; + struct pipe_list **prev = &pipe_list; struct pipe_list *tmp; - if (list->fptr == fptr) { - pipe_list = list->next; - free(list); - return; - } - - while (list->next) { - if (list->next->fptr == fptr) { - tmp = list->next; - list->next = list->next->next; + while ((tmp = *prev) != 0) { + if (tmp->fptr == fptr) { + *prev = tmp->next; free(tmp); return; } - list = list->next; + prev = &tmp->next; } } |