add_hook: do not construct a regex again and again

This commit is contained in:
Maxime Coste 2012-08-29 14:15:13 +02:00
parent 8263adf8c8
commit 8febec0bcf

View File

@ -496,11 +496,10 @@ void add_hook(const CommandParameters& params, Context& context)
throw wrong_argument_count();
// copy so that the lambda gets a copy as well
String regex = params[2];
Regex regex(params[2].begin(), params[2].end());
String command = params[3];
auto hook_func = [=](const String& param, const Context& context) {
if (boost::regex_match(param.begin(), param.end(),
Regex(regex.begin(), regex.end())))
if (boost::regex_match(param.begin(), param.end(), regex))
{
Context new_context(context);
CommandManager::instance().execute(command, new_context);