[newlib-cygwin] Cygwin: fhandler_fifo::delete_client_handler: improve efficiency
Ken Brown
kbrown@sourceware.org
Thu Aug 27 11:14:25 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=49a9ffdf4bcb3388cde5e4f441dd710701136ba7
commit 49a9ffdf4bcb3388cde5e4f441dd710701136ba7
Author: Ken Brown <kbrown@cornell.edu>
Date: Wed Aug 26 18:21:20 2020 -0400
Cygwin: fhandler_fifo::delete_client_handler: improve efficiency
Delete a client handler by swapping it with the last one in the list
instead of calling memmove.
Diff:
---
winsup/cygwin/fhandler_fifo.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index b3c4c4a25..75c8406fe 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -377,14 +377,14 @@ fhandler_fifo::add_client_handler (bool new_pipe_instance)
return 0;
}
-/* Always called with fifo_client_lock in place. */
+/* Always called with fifo_client_lock in place. Delete a
+ client_handler by swapping it with the last one in the list. */
void
fhandler_fifo::delete_client_handler (int i)
{
fc_handler[i].close ();
if (i < --nhandlers)
- memmove (fc_handler + i, fc_handler + i + 1,
- (nhandlers - i) * sizeof (fc_handler[i]));
+ fc_handler[i] = fc_handler[nhandlers];
}
/* Delete handlers that we will never read from. Always called with
More information about the Cygwin-cvs
mailing list