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.
This commit is contained in:
parent
b2f45a29e4
commit
34c489170f
|
@ -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; }));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user