From deb09550d3d0e4ef0db7d2216bc250e68cf67117 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 21 Oct 2019 01:28:20 -0400 Subject: [PATCH] Console: Eliminate redundant strlen call in commandExists() By using the std::string_view constructor for std::string, we can avoid the char* constructor, which would require a strlen call in order to determine the string size. This also allows it to work with non-null-terminated strings. --- hecl/lib/Console.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hecl/lib/Console.cpp b/hecl/lib/Console.cpp index 401b41fbb..0a7673c3f 100644 --- a/hecl/lib/Console.cpp +++ b/hecl/lib/Console.cpp @@ -168,7 +168,7 @@ void Console::listCommands(Console* /*con*/, const std::vector& /*a } bool Console::commandExists(std::string_view cmd) { - std::string cmdName = cmd.data(); + std::string cmdName{cmd}; athena::utility::tolower(cmdName); return m_commands.find(cmdName) != m_commands.end();