From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com 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) From: Simon Marchi 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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. -- 2.42.0