Remove some now unneeded uses of const String& params
HashMap supports finding String from StringView.
This commit is contained in:
parent
a4b82131e5
commit
c1c40a4b56
|
@ -15,7 +15,7 @@
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
bool CommandManager::command_defined(const String& command_name) const
|
bool CommandManager::command_defined(StringView command_name) const
|
||||||
{
|
{
|
||||||
return m_commands.find(command_name) != m_commands.end();
|
return m_commands.find(command_name) != m_commands.end();
|
||||||
}
|
}
|
||||||
|
@ -407,10 +407,10 @@ struct command_not_found : runtime_error
|
||||||
};
|
};
|
||||||
|
|
||||||
CommandManager::CommandMap::const_iterator
|
CommandManager::CommandMap::const_iterator
|
||||||
CommandManager::find_command(const Context& context, const String& name) const
|
CommandManager::find_command(const Context& context, StringView name) const
|
||||||
{
|
{
|
||||||
auto alias = context.aliases()[name];
|
auto alias = context.aliases()[name];
|
||||||
const String& cmd_name = alias.empty() ? name : alias.str();
|
StringView cmd_name = alias.empty() ? name : alias;
|
||||||
|
|
||||||
return m_commands.find(cmd_name);
|
return m_commands.find(cmd_name);
|
||||||
}
|
}
|
||||||
|
@ -628,10 +628,10 @@ Completions CommandManager::complete(const Context& context,
|
||||||
if (tokens[cmd_idx].type() != Token::Type::Raw)
|
if (tokens[cmd_idx].type() != Token::Type::Raw)
|
||||||
return Completions{};
|
return Completions{};
|
||||||
|
|
||||||
const String& command_name = tokens[cmd_idx].content();
|
StringView command_name = tokens[cmd_idx].content();
|
||||||
if (command_name != m_last_complete_command)
|
if (command_name != m_last_complete_command)
|
||||||
{
|
{
|
||||||
m_last_complete_command = command_name;
|
m_last_complete_command = command_name.str();
|
||||||
flags |= CompletionFlags::Start;
|
flags |= CompletionFlags::Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,10 +676,10 @@ Completions CommandManager::complete(const Context& context,
|
||||||
return complete_command_name(context, prefix, true);
|
return complete_command_name(context, prefix, true);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const String& command_name = params[0];
|
StringView command_name = params[0];
|
||||||
if (command_name != m_last_complete_command)
|
if (command_name != m_last_complete_command)
|
||||||
{
|
{
|
||||||
m_last_complete_command = command_name;
|
m_last_complete_command = command_name.str();
|
||||||
flags |= CompletionFlags::Start;
|
flags |= CompletionFlags::Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public:
|
||||||
Optional<CommandInfo> command_info(const Context& context,
|
Optional<CommandInfo> command_info(const Context& context,
|
||||||
StringView command_line) const;
|
StringView command_line) const;
|
||||||
|
|
||||||
bool command_defined(const String& command_name) const;
|
bool command_defined(StringView command_name) const;
|
||||||
|
|
||||||
void register_command(String command_name, Command command,
|
void register_command(String command_name, Command command,
|
||||||
String docstring,
|
String docstring,
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
int m_command_depth = 0;
|
int m_command_depth = 0;
|
||||||
|
|
||||||
CommandMap::const_iterator find_command(const Context& context,
|
CommandMap::const_iterator find_command(const Context& context,
|
||||||
const String& name) const;
|
StringView name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
String expand(StringView str, const Context& context,
|
String expand(StringView str, const Context& context,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user