public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: fhandler_fifo::delete_client_handler: improve efficiency
Date: Thu, 27 Aug 2020 11:14:25 +0000 (GMT) [thread overview]
Message-ID: <20200827111425.4A519386F804@sourceware.org> (raw)
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
reply other threads:[~2020-08-27 11:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200827111425.4A519386F804@sourceware.org \
--to=kbrown@sourceware.org \
--cc=cygwin-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).