diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-04-10 21:33:20 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-04-10 21:33:20 +0100 |
| commit | c1c40a4b56ef62a960a193cce2324cd966a6b4f7 (patch) | |
| tree | 1556777f05c54e5b5d949e1fc76634bbd68da129 /src | |
| parent | a4b82131e5e8af85599e5d86b52db6f128a7f5f1 (diff) | |
Remove some now unneeded uses of const String& params
HashMap supports finding String from StringView.
Diffstat (limited to 'src')
| -rw-r--r-- | src/command_manager.cc | 14 | ||||
| -rw-r--r-- | src/command_manager.hh | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index 155eb0c7..ba8b29e2 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -15,7 +15,7 @@ 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(); } @@ -407,10 +407,10 @@ struct command_not_found : runtime_error }; 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]; - const String& cmd_name = alias.empty() ? name : alias.str(); + StringView cmd_name = alias.empty() ? name : alias; return m_commands.find(cmd_name); } @@ -628,10 +628,10 @@ Completions CommandManager::complete(const Context& context, if (tokens[cmd_idx].type() != Token::Type::Raw) return Completions{}; - const String& command_name = tokens[cmd_idx].content(); + StringView command_name = tokens[cmd_idx].content(); if (command_name != m_last_complete_command) { - m_last_complete_command = command_name; + m_last_complete_command = command_name.str(); flags |= CompletionFlags::Start; } @@ -676,10 +676,10 @@ Completions CommandManager::complete(const Context& context, return complete_command_name(context, prefix, true); else { - const String& command_name = params[0]; + StringView command_name = params[0]; if (command_name != m_last_complete_command) { - m_last_complete_command = command_name; + m_last_complete_command = command_name.str(); flags |= CompletionFlags::Start; } diff --git a/src/command_manager.hh b/src/command_manager.hh index c0442255..0bf0bfdb 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -93,7 +93,7 @@ public: Optional<CommandInfo> command_info(const Context& context, 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, String docstring, @@ -127,7 +127,7 @@ private: int m_command_depth = 0; CommandMap::const_iterator find_command(const Context& context, - const String& name) const; + StringView name) const; }; String expand(StringView str, const Context& context, |
