event: Pass name as wcstring

This passed a wchar_t, only to then construct a wcstring out of it.
Instead let's just pass it directly and move it.
This commit is contained in:
Fabian Homborg 2022-03-25 15:14:24 +01:00
parent ac888ac6af
commit f98398b418
3 changed files with 4 additions and 6 deletions

View File

@ -492,11 +492,9 @@ void event_print(io_streams_t &streams, const wcstring &type_filter) {
}
}
void event_fire_generic(parser_t &parser, const wchar_t *name, const wcstring_list_t *args) {
assert(name && "Null name");
void event_fire_generic(parser_t &parser, wcstring name, const wcstring_list_t *args) {
event_t ev(event_type_t::generic);
ev.desc.str_param1 = name;
ev.desc.str_param1 = std::move(name);
if (args) ev.arguments = *args;
event_fire(parser, ev);
}

View File

@ -162,7 +162,7 @@ void event_print(io_streams_t &streams, const wcstring &type_filter);
wcstring event_get_desc(const parser_t &parser, const event_t &e);
/// Fire a generic event with the specified name.
void event_fire_generic(parser_t &parser, const wchar_t *name,
void event_fire_generic(parser_t &parser, wcstring name,
const wcstring_list_t *args = nullptr);
#endif

View File

@ -4011,7 +4011,7 @@ maybe_t<wcstring> reader_data_t::readline(int nchars_or_0) {
first_prompt = false;
if (!conf.event.empty()) {
event_fire_generic(parser(), conf.event.c_str());
event_fire_generic(parser(), conf.event);
}
exec_prompt();