From 32e61842106f357c115495a10eda7a68ac273f6d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 7 Feb 2013 19:25:07 +0100 Subject: [PATCH] context_wrap: create a DynamicSelectionList only when needed --- src/commands.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 96d06d66..938d365e 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -554,17 +554,15 @@ void context_wrap(const CommandParameters& params, Context& context, Func func) ClientManager::instance().get_client_context(parser.option_value("client")) : context; - const bool restore_selections = parser.has_option("restore-selections"); - Editor& editor = real_context.editor(); - DynamicSelectionList sels(editor.buffer()); - if (restore_selections) - sels = editor.selections(); - auto restore_editor = on_scope_end([&]{ - if (restore_selections) - editor.select(sels); - }); - - func(parser, real_context); + if (parser.has_option("restore-selections")) + { + Editor& editor = real_context.editor(); + DynamicSelectionList sels(editor.buffer(), editor.selections()); + auto restore_sels = on_scope_end([&]{ editor.select(sels); }); + func(parser, real_context); + } + else + func(parser, real_context); } void exec_string(const CommandParameters& params, Context& context)