diff options
| author | Johannes Altmanninger <aclopte@gmail.com> | 2022-07-19 13:12:44 +0200 |
|---|---|---|
| committer | Johannes Altmanninger <aclopte@gmail.com> | 2022-07-21 16:48:44 +0200 |
| commit | 34c489170f94a23493b958514039cc839d6a3f0d (patch) | |
| tree | 1b0993f8e1ad44875e3a696712f44086631c0444 /src/register_manager.cc | |
| parent | b2f45a29e4ef7680b864e910912c301439445415 (diff) | |
Elide temporary vector when completing register names
Just like in the parent commit, this requires us to use a non-owning
type. Technically, these strings all benefit from SSO, so there is
no lifetime issue, but we can't deduce that from the types.
I guess we could use InplaceString just as well.
Diffstat (limited to 'src/register_manager.cc')
| -rw-r--r-- | src/register_manager.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/register_manager.cc b/src/register_manager.cc index f5a6269b..16db41ba 100644 --- a/src/register_manager.cc +++ b/src/register_manager.cc @@ -58,7 +58,7 @@ const String& HistoryRegister::get_main(const Context&, size_t) return m_content.empty() ? String::ms_empty : m_content.front(); } -static const HashMap<String, Codepoint> reg_names = { +static const HashMap<StringView, Codepoint> reg_names { { "slash", '/' }, { "dquote", '"' }, { "pipe", '|' }, @@ -101,7 +101,7 @@ void RegisterManager::add_register(Codepoint c, std::unique_ptr<Register> reg) CandidateList RegisterManager::complete_register_name(StringView prefix, ByteCount cursor_pos) const { - return complete(prefix, cursor_pos, reg_names | transform([](auto& i) { return i.key; }) | gather<Vector<String>>()); + return complete(prefix, cursor_pos, reg_names | transform([](auto& i) { return i.key; })); } } |
