]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: fhandler_fifo::cleanup_handlers: improve efficiency
authorKen Brown <kbrown@cornell.edu>
Thu, 19 Nov 2020 20:22:56 +0000 (15:22 -0500)
committerKen Brown <kbrown@cornell.edu>
Thu, 19 Nov 2020 20:22:56 +0000 (15:22 -0500)
Traverse the fifo_client_handler list from the top down to try to
avoid copying.

winsup/cygwin/fhandler_fifo.cc

index eff05d242e43d562fd36cf9c527a90f876817925..8b67037cb7a42b2ff612f71273951692c65d5702 100644 (file)
@@ -395,15 +395,10 @@ fhandler_fifo::delete_client_handler (int i)
 void
 fhandler_fifo::cleanup_handlers ()
 {
-  int i = 0;
-
-  while (i < nhandlers)
-    {
-      if (fc_handler[i].get_state () < fc_connected)
-       delete_client_handler (i);
-      else
-       i++;
-    }
+  /* Work from the top down to try to avoid copying. */
+  for (int i = nhandlers - 1; i >= 0; --i)
+    if (fc_handler[i].get_state () < fc_connected)
+      delete_client_handler (i);
 }
 
 /* Always called with fifo_client_lock in place. */
This page took 0.031738 seconds and 5 git commands to generate.