public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: sigproc: Eliminate redundant copying of chld_procs Date: Fri, 28 Aug 2020 17:38:23 +0000 (GMT) [thread overview] Message-ID: <20200828173823.28E18393C86F@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b05b0b78fa91514473b092877da0f13be5a6b2c5 commit b05b0b78fa91514473b092877da0f13be5a6b2c5 Author: Corinna Vinschen <corinna@vinschen.de> Date: Fri Aug 28 19:34:52 2020 +0200 Cygwin: sigproc: Eliminate redundant copying of chld_procs On PROC_EXEC_CLEANUP, the pinfo's in chld_procs are removed. This is done in a loop always removing the child with index 0. This, however, results in copying the last child's pinfo in chld_procs to position 0. Do this for 100 children and you get 99 entirely useless copy operations. Fix this by calling remove_proc in reverse order. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/sigproc.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index f46d3d0d8..aa946fb4c 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -299,8 +299,10 @@ proc_subproc (DWORD what, uintptr_t val) goto scan_wait; case PROC_EXEC_CLEANUP: + /* Cleanup backwards to eliminate redundant copying of chld_procs + array members inside remove_proc. */ while (chld_procs.count ()) - remove_proc (0); + remove_proc (chld_procs.count () - 1); for (w = &waitq_head; w->next != NULL; w = w->next) CloseHandle (w->next->ev); break;
reply other threads:[~2020-08-28 17:38 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=20200828173823.28E18393C86F@sourceware.org \ --to=corinna@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: linkBe 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).