public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 4/4] [gdb/tui] Make translate return entry->value instead of entry
Date: Fri, 23 Jun 2023 13:15:36 +0200	[thread overview]
Message-ID: <20230623111536.1623-4-tdevries@suse.de> (raw)
In-Reply-To: <20230623111536.1623-1-tdevries@suse.de>

The only use of "entry = translate (...)" is entry->value.

Simplify using the function by returning entry->value instead.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 2cc81778f3a..93cf45ed296 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -223,14 +223,14 @@ chtype tui_border_lrcorner;
 int tui_border_attrs;
 int tui_active_border_attrs;
 
-/* Identify the item in the translation table.  */
-static struct tui_translate *
+/* Identify the item in the translation table, and return the corresponding value.  */
+static int
 translate (const char *name, struct tui_translate *table)
 {
   while (table->name)
     {
       if (name && strcmp (table->name, name) == 0)
-	return table;
+	return table->value;
       table++;
     }
 
@@ -247,7 +247,7 @@ translate_acs (const char *name, struct tui_translate *table, int acs_char)
   if (strcmp (name, "acs") == 0)
     return acs_char;
 
-  return translate (name, table)->value;
+  return translate (name, table);
 }
 
 /* Update the tui internal configuration according to gdb settings.
@@ -257,20 +257,18 @@ bool
 tui_update_variables ()
 {
   bool need_redraw = false;
-  struct tui_translate *entry;
+  int val;
 
-  entry = translate (tui_border_mode, tui_border_mode_translate);
-  need_redraw
-    |= assign_return_if_changed<int> (tui_border_attrs, entry->value);
+  val = translate (tui_border_mode, tui_border_mode_translate);
+  need_redraw |= assign_return_if_changed<int> (tui_border_attrs, val);
 
-  entry = translate (tui_active_border_mode, tui_border_mode_translate);
-  need_redraw
-    |= assign_return_if_changed<int> (tui_active_border_attrs, entry->value);
+  val = translate (tui_active_border_mode, tui_border_mode_translate);
+  need_redraw |= assign_return_if_changed<int> (tui_active_border_attrs, val);
 
   /* If one corner changes, all characters are changed.  Only check the first
      one.  */
-  int val = translate_acs (tui_border_kind, tui_border_kind_translate_corner,
-			   ACS_LRCORNER);
+  val = translate_acs (tui_border_kind, tui_border_kind_translate_corner,
+		       ACS_LRCORNER);
   need_redraw |= assign_return_if_changed<chtype> (tui_border_lrcorner, val);
 
   tui_border_llcorner
-- 
2.35.3


  parent reply	other threads:[~2023-06-23 11:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23 11:15 [PATCH 1/4] [gdb/tui] Remove default entries in TUI translation tables Tom de Vries
2023-06-23 11:15 ` [PATCH 2/4] [gdb/tui] Introduce translate_acs Tom de Vries
2023-06-23 20:28   ` Tom Tromey
2023-06-23 11:15 ` [PATCH 3/4] [gdb/tui] Merge tui border-kind corner translation tables Tom de Vries
2023-06-23 20:30   ` Tom Tromey
2023-06-23 11:15 ` Tom de Vries [this message]
2023-06-23 20:30   ` [PATCH 4/4] [gdb/tui] Make translate return entry->value instead of entry Tom Tromey
2023-06-23 20:28 ` [PATCH 1/4] [gdb/tui] Remove default entries in TUI translation tables Tom Tromey

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=20230623111536.1623-4-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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).