From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [pushed] Lower variable definitions in tui_redisplay_readline
Date: Sat, 30 Mar 2024 12:21:02 -0600 [thread overview]
Message-ID: <20240330182102.1733633-1-tom@tromey.com> (raw)
I noticed a redundant assignment to 'prev_col' in
tui_redisplay_readline, and then went ahead and lowered most of the
variable definitions in that function to their initialization point.
---
gdb/tui/tui-io.c | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 34e85de0853..2673397cc46 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -564,15 +564,7 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
void
tui_redisplay_readline (void)
{
- int prev_col;
- int height;
- int col;
- int c_pos;
- int c_line;
- int in;
- WINDOW *w;
const char *prompt;
- int start_line;
/* Detect when we temporarily left SingleKey and now the readline
edit buffer is empty, automatically restore the SingleKey
@@ -588,18 +580,17 @@ tui_redisplay_readline (void)
else
prompt = rl_display_prompt;
- c_pos = -1;
- c_line = -1;
- w = TUI_CMD_WIN->handle.get ();
- start_line = TUI_CMD_WIN->start_line;
+ int c_pos = -1;
+ int c_line = -1;
+ WINDOW *w = TUI_CMD_WIN->handle.get ();
+ int start_line = TUI_CMD_WIN->start_line;
wmove (w, start_line, 0);
- prev_col = 0;
- height = 1;
+ int height = 1;
if (prompt != nullptr)
tui_puts_internal (w, prompt, &height);
- prev_col = getcurx (w);
- for (in = 0; in <= rl_end; in++)
+ int prev_col = getcurx (w);
+ for (int in = 0; in <= rl_end; in++)
{
unsigned char c;
@@ -620,7 +611,7 @@ tui_redisplay_readline (void)
else if (c == '\t')
{
/* Expand TABs, since ncurses on MS-Windows doesn't. */
- col = getcurx (w);
+ int col = getcurx (w);
do
{
waddch (w, ' ');
@@ -633,7 +624,7 @@ tui_redisplay_readline (void)
}
if (c == '\n')
TUI_CMD_WIN->start_line = getcury (w);
- col = getcurx (w);
+ int col = getcurx (w);
if (col < prev_col)
height++;
prev_col = col;
--
2.43.0
reply other threads:[~2024-03-30 18:21 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=20240330182102.1733633-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@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).