From patchwork Sat Mar 30 18:21:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 87848 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 97EFA3858D37 for ; Sat, 30 Mar 2024 18:21:37 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id E82983858D28 for ; Sat, 30 Mar 2024 18:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E82983858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E82983858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711822879; cv=none; b=wXA2CK5LIKeGWslHcmNuUDqvbyWNqkKIJ7ppCrRH89uj096idiEqBwv0Da1iXdphtVnB5EXUHOsjr8bhoAPq8YO3BRPMVx2GX5tbgtfZqTETMtXsfVk8ifGBHJ3Pld/oMyFgPMCJZVWQ45CQSyymF/2WBpuURkQu2043sTRMBeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711822879; c=relaxed/simple; bh=h1uI6pGure2k974NbQ705iMhpapb6hGlArWQG5BHsUg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ttCD7bs7l9mQQRk/BfqFL650l5zqQNIY36XylWtQAr4nmR6IF5kh8BRkaNWEplGDMbmpmtryLvfDfw2fzb38lzLPBD6NodvSF/eiiMi5Fu3xJYgN8jVllUe+k86nDoG2AUstQH09BL4tg5j5zyFkQ+SHii6M9zQRNT/Ifm7ZRe0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5008a.ext.cloudfilter.net ([10.0.29.246]) by cmsmtp with ESMTPS id qc7TrH6kxQr4SqdKNrAey3; Sat, 30 Mar 2024 18:21:15 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id qdKMrx7pgiDneqdKMrNEka; Sat, 30 Mar 2024 18:21:15 +0000 X-Authority-Analysis: v=2.4 cv=Cd4O5qrl c=1 sm=1 tr=0 ts=6608581b a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=K6JAEmCyrfEA:10 a=Qbun_eYptAEA:10 a=hHTVmqZwWn9Qn4Qv38wA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=6AiXjsBZV4Q2k8l6KnYt7Kft5dnHUZcul2WeQT6Mb2I=; b=bIKqpfHp4QGZ6mImzqxaS8txRS ef8164S/aEetkO6uZGRBfySGXui7yFVo24j7x88N/7W/Ja0PklqKhASb8CalywT7jHx68XLTpJFvB XKTOEg63h4CP1YqbuKMfxnkRa; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:51206 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rqdKM-001Uha-0d; Sat, 30 Mar 2024 12:21:14 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Lower variable definitions in tui_redisplay_readline Date: Sat, 30 Mar 2024 12:21:02 -0600 Message-ID: <20240330182102.1733633-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.82.115 X-Source-L: No X-Exim-ID: 1rqdKM-001Uha-0d X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net (localhost.localdomain) [97.122.82.115]:51206 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNh/CIcSdpwiFA6rNw0QM48jNvooIZ4725i3u3gOdpXWA+DdAdbi1Fp59gRMfjZVFiouRXx3J/0s6sA/SkCpOZnDsMdUjVozg74/I3l1TSUyxPbWmv4l Rsph/atax6H/0rOCIlEDFOlgqPEPazZeabwfERfLOiBf850Xy7HGyKn5/KxnVKug1NUErLbpXbupglYOpx9YkP9wV/kjXPEpBNo= X-Spam-Status: No, score=-3021.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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;