From c1c40a4b56ef62a960a193cce2324cd966a6b4f7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 10 Apr 2017 21:33:20 +0100 Subject: [PATCH] Remove some now unneeded uses of const String& params HashMap supports finding String from StringView. --- src/command_manager.cc | 14 +++++++------- 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 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,