From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B992C3858020 for ; Wed, 25 Jan 2023 12:09:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B992C3858020 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674648549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kN+TGSrhUsQB6Jmk1CbxK2TEbZTQtMX16sxb/eKGfhc=; b=T+1xftXoqiFPBwaQwPtvfGSaoLCUX2OFUplXinO8QvKJw9on1hQaEKqGM1L6JW6BntJ3XW RK7kxemaDxA0rNQ7ycz6P9wiDtbW58m1ivrm8tEXscuDwt6vu5ZWN6PxcrW5rhXh0db1kP YIqqhIo/MJ5kQfYhT1WG2POKEBVG9Ug= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-308-BqgU5x3ZNH6zGFE0GHcURA-1; Wed, 25 Jan 2023 07:09:08 -0500 X-MC-Unique: BqgU5x3ZNH6zGFE0GHcURA-1 Received: by mail-qk1-f197.google.com with SMTP id a3-20020a05620a438300b007069b068069so12705201qkp.2 for ; Wed, 25 Jan 2023 04:09:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kN+TGSrhUsQB6Jmk1CbxK2TEbZTQtMX16sxb/eKGfhc=; b=oiA8fJV7+S2FNpOV1nXMlehuuxhSYyZj+s516UFfaHV0ZWxvjRH77TBRSwLtguFgnU UmMLBCq4Q71whlTTbvthwOPuUa4rddGWooZ2lh+lDqdEUVg3/+5je16YEFXSPwmOvx8Z zF2bhkNHE8tS5PYmGMYjIHsHk9E81SZ0ZZHcJQrGXkdV7GOGp9JTz7IVJS5Zcz/jFeOY Q99WFWvQLKNlFswXZQHffUNcR7+RU3Xbi2jc/bSIuv7bpiu8a0IJXD587bMpt4V3YMS0 PNE393qHpjf3iMbQlxZUilTB35v69ZzOYlznSWr/amWNc7W+yXSHP9BskfqW/oNedpyw ZUzw== X-Gm-Message-State: AFqh2koC+P3sJTvCKB0p8QfpouxrdLmkkk5LSHZ+YkNawtiZ0KsF8odq NTzJZN9ol+wqldQlQ6qVUBiIdqrH4dXEUYVOc9DeSzN59hqn0UkzUcxmxs65uUG9msem0RbKfEH gA/rwdGdBL2bZK7/9jwjjBZTZ/EEQDRWvanB3vQmJxNciOpGUq122a0sjX3+eAc1FdJ+jtgCblQ == X-Received: by 2002:ac8:6659:0:b0:3b6:2c74:b67f with SMTP id j25-20020ac86659000000b003b62c74b67fmr37925290qtp.13.1674648547716; Wed, 25 Jan 2023 04:09:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9DzlUGsHT55qs3QTp1CefT+p4PDHoYXmpKwc/7IxL9OOl8ADWPiO5nrskYwPG0xxpjIKVdQ== X-Received: by 2002:ac8:6659:0:b0:3b6:2c74:b67f with SMTP id j25-20020ac86659000000b003b62c74b67fmr37925263qtp.13.1674648547376; Wed, 25 Jan 2023 04:09:07 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id l6-20020ac80786000000b003a530a32f67sm3107642qth.65.2023.01.25.04.09.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 04:09:07 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 6/8] gdb/tui: avoid extra refresh_window on horizontal scroll Date: Wed, 25 Jan 2023 12:08:46 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. 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. 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. 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. There should be no user visible changes after this commit. --- 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 ()); - 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 = 0; lineno < m_content.size (); lineno++) show_source_line (lineno); - 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 (); } tui_source_window_base::tui_source_window_base () -- 2.25.4