Fix performance problem when generating many values for # register

Fixes #2008
This commit is contained in:
Maxime Coste 2018-05-09 22:40:40 +10:00
parent 3c29bf1ea6
commit 288cf6de73

View File

@ -228,9 +228,10 @@ void register_registers()
register_manager.add_register('#', make_dyn_reg( register_manager.add_register('#', make_dyn_reg(
[](const Context& context) { [](const Context& context) {
const size_t count = context.selections().size();
StringList res; StringList res;
res.reserve(context.selections().size()); res.reserve(count);
for (size_t i = 1; i < context.selections().size()+1; ++i) for (size_t i = 1; i < count+1; ++i)
res.push_back(to_string((int)i)); res.push_back(to_string((int)i));
return res; return res;
})); }));