From b89c8f2fc73e25f1740c191faf0c7e8b9c18c9b9 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Tue, 12 Jun 2018 21:56:16 +0900 Subject: Use std::vector::reserve --- include/tgbot/TgTypeParser.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/tgbot/TgTypeParser.h b/include/tgbot/TgTypeParser.h index a24184a..6df9f36 100644 --- a/include/tgbot/TgTypeParser.h +++ b/include/tgbot/TgTypeParser.h @@ -314,6 +314,7 @@ public: template std::vector> parseJsonAndGetArray(JsonToTgTypeFunc parseFunc, const boost::property_tree::ptree& data) const { std::vector> result; + result.reserve(data.size()); for (const std::pair& innerTreeItem : data) { result.push_back((this->*parseFunc)(innerTreeItem.second)); } @@ -327,6 +328,7 @@ public: if (treeItem == data.not_found()) { return result; } + result.reserve(treeItem->second.size()); for (const std::pair& innerTreeItem : treeItem->second) { result.push_back(parseFunc(innerTreeItem.second)); } @@ -340,6 +342,7 @@ public: if (treeItem == data.not_found()) { return result; } + result.reserve(treeItem->second.size()); for (const std::pair& innerTreeItem : treeItem->second) { result.push_back((this->*parseFunc)(innerTreeItem.second)); } @@ -353,6 +356,7 @@ public: if (treeItem == data.not_found()) { return result; } + result.reserve(treeItem->second.size()); for (const std::pair& innerTreeItem : treeItem->second) { std::vector> innerResult; for (const std::pair& innerInnerTreeItem : innerTreeItem.second) { -- cgit v1.2.3