From patchwork Fri Sep 8 18:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 75567 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 01318387689A for ; Fri, 8 Sep 2023 19:03:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 01318387689A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694199837; bh=PljKX5S1YDTktxJOsk+pXCCWGKKVXfyJi/LbXQTYk6g=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=J7hoiywSKWMXfb9jtCXmt7g9vPQmZB+EsEKwv+XNctF7L4h+4wRDamSvzm2ANbsap zqCfbvxq5VA56B2BK3946sT5Vs74fkmDE1z+LrWv44H6h/dfJ9V1eHHB/ENklaOIEZ aUa7dBNKTWWaamlyfHzM6DCwpJYvDm2HkLrouQoY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 077E83858408 for ; Fri, 8 Sep 2023 19:02:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 077E83858408 Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id D45061E110; Fri, 8 Sep 2023 15:02:29 -0400 (EDT) To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 05/21] gdb: remove ui:::add_interp and ui::lookup_existing_interp Date: Fri, 8 Sep 2023 14:22:59 -0400 Message-ID: <20230908190227.96319-6-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230908190227.96319-1-simon.marchi@efficios.com> References: <20230908190227.96319-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3497.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, 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: , X-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" These two methods are only used internally, in ui::lookup_interp. I first thought of making them private, but really I think we can just inline their code in ui::lookup_interp, it's nothing fancy. Change-Id: Ib65c7d49b698a6a57722c148a228bb18888c4e42 --- gdb/ui.c | 32 +++++--------------------------- gdb/ui.h | 8 -------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/gdb/ui.c b/gdb/ui.c index a7b81c077e9a..4bb63ed63030 100644 --- a/gdb/ui.c +++ b/gdb/ui.c @@ -147,28 +147,6 @@ ui::register_file_handler () string_printf ("ui-%d", num), true); } -/* See ui.h. */ - -interp * -ui::lookup_existing_interp (const char *name) const -{ - for (interp &interp : this->interp_list) - if (strcmp (interp.name (), name) == 0) - return &interp; - - return nullptr; -} - -/* See ui.h. */ - -void -ui::add_interp (interp *interp) -{ - gdb_assert (this->lookup_existing_interp (interp->name ()) == nullptr); - - this->interp_list.push_back (*interp); -} - /* See interps.h. */ interp * @@ -178,16 +156,16 @@ ui::lookup_interp (const char *name) return nullptr; /* Only create each interpreter once per UI. */ - interp *interp = this->lookup_existing_interp (name); - if (interp != nullptr) - return interp; + for (auto &candidate : this->interp_list) + if (strcmp (candidate.name (), name) == 0) + return &candidate; const interp_factory *factory = find_interp_factory (name); if (factory == nullptr) return nullptr; - interp = factory->func (factory->name); - this->add_interp (interp); + interp *interp = factory->func (factory->name); + this->interp_list.push_back (*interp); return interp; } diff --git a/gdb/ui.h b/gdb/ui.h index aeb26c68823a..b9ca9c0c80a0 100644 --- a/gdb/ui.h +++ b/gdb/ui.h @@ -159,19 +159,11 @@ struct ui : public intrusive_list_node /* Return true if this UI's input fd is a tty. */ bool input_interactive_p () const; - /* Look up the interpreter for NAME. If no such interpreter exists, - return nullptr, otherwise return a pointer to the interpreter. */ - interp *lookup_existing_interp (const char *name) const; - /* Look up the interpreter for NAME, creating one if none exists yet. If NAME is not a interpreter type previously registered with interp_factory_register, return nullptr; otherwise return a pointer to the interpreter. */ interp *lookup_interp (const char *name); - - /* Add interpreter INTERP to this UI's interpreter list. The - interpreter must not have previously been added. */ - void add_interp (interp *interp); }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr.