public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 2/2] [gdb/tui] Simplify tui_update_variables
Date: Thu,  8 Jun 2023 11:17:14 +0200	[thread overview]
Message-ID: <20230608091714.19546-2-tdevries@suse.de> (raw)
In-Reply-To: <20230608091714.19546-1-tdevries@suse.de>

Simplify tui_update_variables by using template function
assign_return_if_changed.

Tested on x86_64-linux.
---
 gdb/tui/tui-win.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 71f961e04d2..3e2605ff24a 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -284,28 +284,20 @@ tui_update_variables ()
   struct tui_translate *entry;
 
   entry = translate (tui_border_mode, tui_border_mode_translate);
-  if (tui_border_attrs != entry->value)
-    {
-      tui_border_attrs = entry->value;
-      need_redraw = true;
-    }
+  need_redraw
+    |= assign_return_if_changed<int> (tui_border_attrs, entry->value);
+
   entry = translate (tui_active_border_mode, tui_border_mode_translate);
-  if (tui_active_border_attrs != entry->value)
-    {
-      tui_active_border_attrs = entry->value;
-      need_redraw = true;
-    }
+  need_redraw
+    |= assign_return_if_changed<int> (tui_active_border_attrs, entry->value);
 
   /* If one corner changes, all characters are changed.
      Only check the first one.  The ACS characters are determined at
      run time by curses terminal management.  */
   entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
   int val = (entry->value < 0) ? ACS_LRCORNER : entry->value;
-  if (tui_border_lrcorner != (chtype) val)
-    {
-      tui_border_lrcorner = val;
-      need_redraw = true;
-    }
+  need_redraw |= assign_return_if_changed<chtype> (tui_border_lrcorner, val);
+
   entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
   tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
 
-- 
2.35.3


  reply	other threads:[~2023-06-08  9:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08  9:17 [PATCH v2 1/2] [gdb] Add template functions assign_return/set_if_changed Tom de Vries
2023-06-08  9:17 ` Tom de Vries [this message]
2023-06-19  9:19 ` Tom de Vries

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=20230608091714.19546-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --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).