4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-08 18:19:08 +08:00

Cygwin: fhandler_fifo::cleanup_handlers: improve efficiency

Traverse the fifo_client_handler list from the top down to try to
avoid copying.
This commit is contained in:
Ken Brown 2020-11-19 15:22:56 -05:00
parent 0cd9136981
commit 1395b4ea2c

View File

@ -395,15 +395,10 @@ fhandler_fifo::delete_client_handler (int i)
void void
fhandler_fifo::cleanup_handlers () fhandler_fifo::cleanup_handlers ()
{ {
int i = 0; /* Work from the top down to try to avoid copying. */
for (int i = nhandlers - 1; i >= 0; --i)
while (i < nhandlers) if (fc_handler[i].get_state () < fc_connected)
{ delete_client_handler (i);
if (fc_handler[i].get_state () < fc_connected)
delete_client_handler (i);
else
i++;
}
} }
/* Always called with fifo_client_lock in place. */ /* Always called with fifo_client_lock in place. */