diff --git a/include/tc/core.hpp b/include/tc/core.hpp index 8594adc..7f91889 100644 --- a/include/tc/core.hpp +++ b/include/tc/core.hpp @@ -55,14 +55,15 @@ namespace tc { std::vector gens, std::function op ) const { - std::vector res(size()); - res[0] = start; + std::vector res; + res.reserve(size()); + res.push_back(start); - for (int i = 1; i < res.size(); ++i) { + for (int i = 1; i < size(); ++i) { auto &action = path[i]; auto &from = res[action.from_idx]; auto &val = gens[action.gen]; - res[i] = op(from, val); + res.push_back(op(from, val)); } return res; @@ -73,10 +74,11 @@ namespace tc { T start, std::function op ) const { - std::vector res(size()); - res[0] = start; + std::vector res; + res.reserve(size()); + res.push_back(start); - for (int i = 1; i < res.size(); ++i) { + for (int i = 1; i < size(); ++i) { auto &action = path[i]; auto &from = res[action.from_idx]; auto &val = action.gen; @@ -127,7 +129,7 @@ namespace tc { struct SubGroup; struct Group { - const int ngens; + int ngens; std::vector> _mults; std::string name;