From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 1BADC3858D37; Tue, 1 Mar 2022 23:50:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BADC3858D37 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: console: Stop to create struct instance which is not needed. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 3e4dd6cc48d22ad2d2a522bb3d647fb6a65ff4f9 X-Git-Newrev: 2b4d4728f23408308dbb3046f6e17d09039f3b50 Message-Id: <20220301235011.1BADC3858D37@sourceware.org> Date: Tue, 1 Mar 2022 23:50:11 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Mar 2022 23:50:11 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D2b4d4728f23= 408308dbb3046f6e17d09039f3b50 commit 2b4d4728f23408308dbb3046f6e17d09039f3b50 Author: Takashi Yano Date: Wed Mar 2 08:35:09 2022 +0900 Cygwin: console: Stop to create struct instance which is not needed. =20 - In fhandler_console::cons_master_thread(), a struct which has only a static function is used. In this case, struct instance is not necessary. So with this patch, the static function is invoked without creating instance. Diff: --- winsup/cygwin/fhandler_console.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_con= sole.cc index 920dd4be0..2a4aa7a70 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -192,13 +192,13 @@ fhandler_console::cons_master_thread (handle_set_t *p= , tty *ttyp) during the process. Additional space should be left for writeback fix. */ const int inrec_size =3D INREC_SIZE + additional_space; - struct + struct m { inline static size_t bytes (size_t n) { return sizeof (INPUT_RECORD) * n; } - } m; + }; termios &ti =3D ttyp->ti; int processed_up_to =3D -1; while (con.owner =3D=3D myself->pid) @@ -227,7 +227,7 @@ fhandler_console::cons_master_thread (handle_set_t *p, = tty *ttyp) ReadConsoleInputW (p->input_handle, input_rec + total_read, incr, &n); /* Discard oldest n events. */ - memmove (input_rec, input_rec + n, m.bytes (total_read)); + memmove (input_rec, input_rec + n, m::bytes (total_read)); processed_up_to -=3D n; nowait =3D true; } @@ -307,7 +307,7 @@ remove_record: { /* Remove corresponding record. */ if (total_read > i + 1) memmove (input_rec + i, input_rec + i + 1, - m.bytes (total_read - i - 1)); + m::bytes (total_read - i - 1)); total_read--; i--; } @@ -325,21 +325,21 @@ remove_record: if (n < total_read) break; /* Someone has read input without acquiring input_mutex. ConEmu cygwin-connector? */ - if (memcmp (input_rec, tmp, m.bytes (total_read)) =3D=3D 0) + if (memcmp (input_rec, tmp, m::bytes (total_read)) =3D=3D 0) break; /* OK */ /* Try to fix */ DWORD incr =3D n - total_read; DWORD ofst; for (ofst =3D 1; ofst <=3D incr; ofst++) - if (memcmp (input_rec, tmp + ofst, m.bytes (total_read)) =3D=3D 0) + if (memcmp (input_rec, tmp + ofst, m::bytes (total_read)) =3D=3D 0) { ReadConsoleInputW (p->input_handle, tmp, inrec_size, &n); - memcpy (input_rec, tmp + ofst, m.bytes (total_read)); - memcpy (input_rec + total_read, tmp, m.bytes (ofst)); + memcpy (input_rec, tmp + ofst, m::bytes (total_read)); + memcpy (input_rec + total_read, tmp, m::bytes (ofst)); if (n > ofst + total_read) memcpy (input_rec + total_read + ofst, tmp + ofst + total_read, - m.bytes (n - (ofst + total_read))); + m::bytes (n - (ofst + total_read))); total_read =3D n; break; }