From cbd40382bfbc24e1c7d78c7722038983b9979695 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 21 Oct 2019 00:53:12 -0400 Subject: [PATCH] Console: Convert std::bind to lambda functions Same behavior, but more efficient than wrapping the function. --- hecl/lib/Console.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hecl/lib/Console.cpp b/hecl/lib/Console.cpp index 60f526cc6..06983d279 100644 --- a/hecl/lib/Console.cpp +++ b/hecl/lib/Console.cpp @@ -19,15 +19,17 @@ Console* Console::m_instance = nullptr; Console::Console(CVarManager* cvarMgr) : m_cvarMgr(cvarMgr), m_overwrite(false), m_cursorAtEnd(false) { m_instance = this; registerCommand("help", "Prints information about a given function", "", - std::bind(&Console::help, this, std::placeholders::_1, std::placeholders::_2)); + [this](Console* console, const std::vector& args) { help(console, args); }); registerCommand("listCommands", "Prints a list of all available Commands", "", - std::bind(&Console::listCommands, this, std::placeholders::_1, std::placeholders::_2)); + [this](Console* console, const std::vector& args) { listCommands(console, args); }); registerCommand("listCVars", "Lists all available CVars", "", - std::bind(&CVarManager::list, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); - registerCommand("setCVar", "Sets a given Console Variable to the specified value", " ", - std::bind(&CVarManager::setCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); - registerCommand("getCVar", "Prints the value stored in the specified Console Variable", "", - std::bind(&CVarManager::getCVar, m_cvarMgr, std::placeholders::_1, std::placeholders::_2)); + [this](Console* console, const std::vector& args) { m_cvarMgr->list(console, args); }); + registerCommand( + "setCVar", "Sets a given Console Variable to the specified value", " ", + [this](Console* console, const std::vector& args) { m_cvarMgr->setCVar(console, args); }); + registerCommand( + "getCVar", "Prints the value stored in the specified Console Variable", "", + [this](Console* console, const std::vector& args) { m_cvarMgr->getCVar(console, args); }); m_conSpeed = cvarMgr->findOrMakeCVar("con_speed", "Speed at which the console opens and closes, calculated as pixels per second", 1.f, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);