From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id B4F15385842A; Fri, 27 Jan 2023 16:25:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4F15385842A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674836728; bh=ktAFHhSoWBTPVXl+w5sKsVy2aWVJMKOSyWWRiig9zf8=; h=From:To:Subject:Date:From; b=v2SHL++mr6tRPqiP22NlYyPU8FImIIi2kkA79CTnz4U4A0d59JDWjOF49/2SmC2l+ MydsUkfR36q1XO45wdBSSaAmLWFDYD2wwpm+ImxJMvXA2eGg5DcMu/Ca1ADUfg4ccA SpMGYIoMfe01j5TrfVYY2g6Zatu2ZU/zxsOYRRIU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/tui: avoid extra refresh_window on horizontal scroll X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 6acafdaef76a4505b7cd87d7612d59dee4302f7d X-Git-Newrev: d2a5ea5622ec7a2a3e255186c88d69812f148913 Message-Id: <20230127162528.B4F15385842A@sourceware.org> Date: Fri, 27 Jan 2023 16:25:28 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd2a5ea5622ec= 7a2a3e255186c88d69812f148913 commit d2a5ea5622ec7a2a3e255186c88d69812f148913 Author: Andrew Burgess Date: Thu Jan 5 12:18:05 2023 +0000 gdb/tui: avoid extra refresh_window on horizontal scroll =20 While working on the previous patches I noticed that in some cases I was seeing two calls to tui_source_window_base::refresh_window when scrolling the window horizontally. =20 The two calls would trigger in for the tui-disasm-long-lines.exp test when the pad needed to be refilled. The two called both come from tui_source_window_base::show_source_content. The first call is nested within check_and_display_highlight_if_needed, while the second call is done directly at the end of show_source_content. =20 The check_and_display_highlight_if_needed is being used to draw the window box to the window, this is needed here because show_source_content is what gets called when the window needs updating, e.g. after a resize. We could potentially do the boxing in refresh_window, but then we'd be doing it each time we scroll, even though the box doesn't need changing in this case. =20 However, we can move the check_and_display_highlight_if_needed to be the last thing done in show_source_content, this means that we can rely on the refresh_window call within it to be our single refresh call. =20 There should be no user visible changes after this commit. Diff: --- gdb/tui/tui-winsource.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index 6e22638ec74..50efa80576f 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -348,8 +348,6 @@ tui_source_window_base::show_source_content () { gdb_assert (!m_content.empty ()); =20 - check_and_display_highlight_if_needed (); - /* The pad should be at least as wide as the window, but ideally, as wide as the content, however, for some very wide content this might not be possible. */ @@ -399,7 +397,11 @@ tui_source_window_base::show_source_content () for (int lineno =3D 0; lineno < m_content.size (); lineno++) show_source_line (lineno); =20 - refresh_window (); + /* Calling check_and_display_highlight_if_needed will call refresh_window + (so long as the current window can be boxed), which will ensure that + the newly loaded window content is copied to the screen. */ + gdb_assert (can_box ()); + check_and_display_highlight_if_needed (); } =20 tui_source_window_base::tui_source_window_base ()