* [PATCH] Cygwin: fhandler_fifo::delete_client_handler: improve efficiency
@ 2020-08-27 2:03 Ken Brown
2020-08-27 8:49 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Ken Brown @ 2020-08-27 2:03 UTC (permalink / raw)
To: cygwin-patches
Delete a client handler by swapping it with the last one in the list
instead of calling memmove.
---
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
--
2.28.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Cygwin: fhandler_fifo::delete_client_handler: improve efficiency
2020-08-27 2:03 [PATCH] Cygwin: fhandler_fifo::delete_client_handler: improve efficiency Ken Brown
@ 2020-08-27 8:49 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2020-08-27 8:49 UTC (permalink / raw)
To: cygwin-patches
On Aug 26 22:03, Ken Brown via Cygwin-patches wrote:
> Delete a client handler by swapping it with the last one in the list
> instead of calling memmove.
> ---
> 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
> --
> 2.28.0
Yup, please push.
Thanks,
Corinna
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-27 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 2:03 [PATCH] Cygwin: fhandler_fifo::delete_client_handler: improve efficiency Ken Brown
2020-08-27 8:49 ` Corinna Vinschen
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).