[05/21] gdb: remove ui:::add_interp and ui::lookup_existing_interp
Commit Message
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(-)
@@ -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;
}
@@ -159,19 +159,11 @@ struct ui : public intrusive_list_node<ui>
/* 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.