summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJellyBrick <shlee1503@naver.com>2018-06-12 21:56:16 +0900
committerJellyBrick <shlee1503@naver.com>2018-06-12 21:56:16 +0900
commitb89c8f2fc73e25f1740c191faf0c7e8b9c18c9b9 (patch)
tree6db1b94ea9ca29b72f7788f7f8c62c2ae20222c2 /include
parent093833a785cb25faf4afe3b5652c7598d778866f (diff)
Use std::vector::reserve
Diffstat (limited to 'include')
-rw-r--r--include/tgbot/TgTypeParser.h4
1 files changed, 4 insertions, 0 deletions
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<typename T>
std::vector<std::shared_ptr<T>> parseJsonAndGetArray(JsonToTgTypeFunc<T> parseFunc, const boost::property_tree::ptree& data) const {
std::vector<std::shared_ptr<T>> result;
+ result.reserve(data.size());
for (const std::pair<const std::string, boost::property_tree::ptree>& 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<const std::string, boost::property_tree::ptree>& 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<const std::string, boost::property_tree::ptree>& 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<const std::string, boost::property_tree::ptree>& innerTreeItem : treeItem->second) {
std::vector<std::shared_ptr<T>> innerResult;
for (const std::pair<const std::string, boost::property_tree::ptree>& innerInnerTreeItem : innerTreeItem.second) {