public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 4/5] Cygwin: pty: Prevent pty from changing code page of parent console.
Date: Mon, 18 Jan 2021 20:23:49 +0900	[thread overview]
Message-ID: <20210118202349.b0d9035855eddf53488143d9@nifty.ne.jp> (raw)
In-Reply-To: <20210118102340.GO59030@calimero.vinschen.de>

Hi Corinna,

On Mon, 18 Jan 2021 11:23:40 +0100
Corinna Vinschen wrote:
> I'm going to push patches 1 - 3.  In terms of patch 4 I have a few
> questions:
> 
> On Jan 15 17:32, Takashi Yano via Cygwin-patches wrote:
> > @@ -2185,7 +2185,7 @@ private:
> >    bool send_winch_maybe ();
> >    void setup ();
> >    bool set_unit ();
> > -  static bool need_invisible ();
> > +  static bool need_invisible (bool force=false);
> 
> Please add spaces, i. e., force = false
> 
> > +static DWORD
> > +get_console_process_id (DWORD pid, bool match)
> > +{
> > +  DWORD tmp;
> > +  DWORD num, num_req;
> > +  num = 1;
> > +  num_req = GetConsoleProcessList (&tmp, num);
> > +  DWORD *list;
> 
> So, assuming num_req is 1 after the call, shouldn't that skip the
> rest of the code?
> 
> > +  while (true)
> > +    {
> > +      list = (DWORD *)
> > +	HeapAlloc (GetProcessHeap (), 0, num_req * sizeof (DWORD));
> > +      num = num_req;
> > +      num_req = GetConsoleProcessList (list, num);
> > +      if (num_req > num)
> > +	HeapFree (GetProcessHeap (), 0, list);
> > +      else
> > +	break;
> > +    }
> > +  num = num_req;
> > +
> > +  tmp = 0;
> > +  for (DWORD i=0; i<num; i++)
> > +    if ((match && list[i] == pid) || (!match && list[i] != pid))
> > +      /* Last one is the oldest. */
> > +      /* https://github.com/microsoft/terminal/issues/95 */
> 
> Given that, wouldn't it make more sense to count backwards, from
> num - 1 to 0, from a performance perspective?

Thanks for the advice. I will submit the revised patch.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

  reply	other threads:[~2021-01-18 11:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-15  8:32 [PATCH 0/5] Some revisions for pty and console code Takashi Yano
2021-01-15  8:32 ` [PATCH 1/5] Cygwin: pty: Add workaround for rlwrap 0.40 or later Takashi Yano
2021-01-15  8:32 ` [PATCH 2/5] Cygwin: console: Revise the code to switch xterm mode Takashi Yano
2021-01-15  8:32 ` [PATCH 3/5] Cygwin: pty: Make close_pseudoconsole() be a static member function Takashi Yano
2021-01-15  8:32 ` [PATCH 4/5] Cygwin: pty: Prevent pty from changing code page of parent console Takashi Yano
2021-01-18 10:23   ` Corinna Vinschen
2021-01-18 11:23     ` Takashi Yano [this message]
2021-01-15  8:32 ` [PATCH 5/5] Cygwin: pty: Make master thread functions be static Takashi Yano

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=20210118202349.b0d9035855eddf53488143d9@nifty.ne.jp \
    --to=takashi.yano@nifty.ne.jp \
    --cc=cygwin-patches@cygwin.com \
    /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).