From f98398b4186f431c687308c98a54e4b16492028f Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 25 Mar 2022 15:14:24 +0100 Subject: [PATCH] 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. --- src/event.cpp | 6 ++---- src/event.h | 2 +- src/reader.cpp | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/event.cpp b/src/event.cpp index 7f574d66e..e82316e7c 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -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); } diff --git a/src/event.h b/src/event.h index b647fbd50..9deb2f91d 100644 --- a/src/event.h +++ b/src/event.h @@ -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 diff --git a/src/reader.cpp b/src/reader.cpp index 246ba4792..976134d16 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -4011,7 +4011,7 @@ maybe_t 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();