public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fhandler_fifo::cleanup_handlers: improve efficiency
@ 2020-11-20 13:33 Ken Brown
  0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2020-11-20 13:33 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=11c5fd6abde05956f909729289883599392c39a2

commit 11c5fd6abde05956f909729289883599392c39a2
Author: Ken Brown <kbrown@cornell.edu>
Date:   Thu Nov 19 15:22:56 2020 -0500

    Cygwin: fhandler_fifo::cleanup_handlers: improve efficiency
    
    Traverse the fifo_client_handler list from the top down to try to
    avoid copying.

Diff:
---
 winsup/cygwin/fhandler_fifo.cc | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index eff05d242..8b67037cb 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -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. */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-20 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 13:33 [newlib-cygwin] Cygwin: fhandler_fifo::cleanup_handlers: improve efficiency Ken Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).