From 8febec0bcf48369336cf94bac889ac27d90c6821 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 29 Aug 2012 14:15:13 +0200 Subject: [PATCH] add_hook: do not construct a regex again and again --- src/commands.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index ac0467a8..7b636d5f 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -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);