From daf7b90b725ce30893d83db0919fad7835a91156 Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Fri, 29 Jul 2016 14:35:57 +0200 Subject: [PATCH] use std::move in some places --- src/serialization/string_utils.cpp | 8 ++++---- src/terrain/builder.cpp | 2 +- src/units/abilities.cpp | 4 ++-- src/units/animation.cpp | 4 ++-- src/units/frame.cpp | 8 ++++---- src/units/types.cpp | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/serialization/string_utils.cpp b/src/serialization/string_utils.cpp index ef41f680860..fbfd2304e27 100644 --- a/src/serialization/string_utils.cpp +++ b/src/serialization/string_utils.cpp @@ -125,7 +125,7 @@ std::vector< std::string > split(std::string const &val, const char c, const int if (flags & STRIP_SPACES) strip_end(new_val); if (!(flags & REMOVE_EMPTY) || !new_val.empty()) - res.push_back(new_val); + res.push_back(std::move(new_val)); ++i2; if (flags & STRIP_SPACES) { while (i2 != val.end() && portable_isspace(*i2)) @@ -142,7 +142,7 @@ std::vector< std::string > split(std::string const &val, const char c, const int if (flags & STRIP_SPACES) strip_end(new_val); if (!(flags & REMOVE_EMPTY) || !new_val.empty()) - res.push_back(new_val); + res.push_back(std::move(new_val)); return res; } @@ -430,7 +430,7 @@ std::vector< std::string > parenthetical_split(std::string const &val, if (flags & STRIP_SPACES) strip(new_val); if (!(flags & REMOVE_EMPTY) || !new_val.empty()) - res.push_back(new_val); + res.push_back(std::move(new_val)); if(!part.empty()){ ERR_GENERAL << "Mismatched parenthesis:\n"< quoted_split(std::string const &val, char c, int flag if (flags & STRIP_SPACES) strip(new_val); if (!(flags & REMOVE_EMPTY) || !new_val.empty()) - res.push_back(new_val); + res.push_back(std::move(new_val)); ++i2; if (flags & STRIP_SPACES) { while(i2 != val.end() && *i2 == ' ') diff --git a/src/terrain/builder.cpp b/src/terrain/builder.cpp index 4514bb60c87..95c660f9522 100644 --- a/src/terrain/builder.cpp +++ b/src/terrain/builder.cpp @@ -485,7 +485,7 @@ bool terrain_builder::load_images(building_rule &rule) break; // no valid images, don't register it res.start_animation(0, true); - variant.images.push_back(res); + variant.images.push_back(std::move(res)); } if(variant.images.empty()) return false; //no valid images, rule is invalid diff --git a/src/units/abilities.cpp b/src/units/abilities.cpp index aae70a24a2c..cbe83dd6512 100644 --- a/src/units/abilities.cpp +++ b/src/units/abilities.cpp @@ -212,9 +212,9 @@ std::vector unit::get_ability_list() const std::vector res; for (const config::any_child &ab : this->abilities_.all_children_range()) { - std::string const &id = ab.cfg["id"]; + std::string id = ab.cfg["id"]; if (!id.empty()) - res.push_back(id); + res.push_back(std::move(id)); } return res; } diff --git a/src/units/animation.cpp b/src/units/animation.cpp index 0e9709768d7..947476468d2 100644 --- a/src/units/animation.cpp +++ b/src/units/animation.cpp @@ -1287,7 +1287,7 @@ void unit_animator::add_animation(const unit* animated_unit if(!tmp.animation) return; start_time_ = std::max(start_time_,tmp.animation->get_begin_time()); - animated_units_.push_back(tmp); + animated_units_.push_back(std::move(tmp)); } void unit_animator::add_animation(const unit* animated_unit @@ -1308,7 +1308,7 @@ void unit_animator::add_animation(const unit* animated_unit if(!tmp.animation) return; start_time_ = std::max(start_time_,tmp.animation->get_begin_time()); - animated_units_.push_back(tmp); + animated_units_.push_back(std::move(tmp)); } void unit_animator::replace_anim_if_invalid(const unit* animated_unit diff --git a/src/units/frame.cpp b/src/units/frame.cpp index 93f7cb9bf8e..45632cf2d50 100644 --- a/src/units/frame.cpp +++ b/src/units/frame.cpp @@ -52,12 +52,12 @@ progressive_string::progressive_string(const std::string & data,int duration) : std::vector second_pass = utils::split(*tmp,':'); if(second_pass.size() > 1) { try { - data_.push_back(std::pair(second_pass[0],std::stoi(second_pass[1]))); + data_.push_back(std::pair(std::move(second_pass[0]),std::stoi(second_pass[1]))); } catch(std::invalid_argument) { ERR_NG << "Invalid time in unit animation: " << second_pass[1] << "\n"; } } else { - data_.push_back(std::pair(second_pass[0],time_chunk)); + data_.push_back(std::pair(std::move(second_pass[0]),time_chunk)); } } } @@ -99,12 +99,12 @@ progressive_image::progressive_image(const std::string & data,int duration) : std::vector second_pass = utils::split(*tmp,':'); if(second_pass.size() > 1) { try { - data_.push_back(std::pair(second_pass[0],std::stoi(second_pass[1]))); + data_.push_back(std::pair(std::move(second_pass[0]),std::stoi(second_pass[1]))); } catch(std::invalid_argument) { ERR_NG << "Invalid time in unit animation: " << second_pass[1] << "\n"; } } else { - data_.push_back(std::pair(second_pass[0],time_chunk)); + data_.push_back(std::pair(std::move(second_pass[0]),time_chunk)); } } } diff --git a/src/units/types.cpp b/src/units/types.cpp index 78f98f67c9e..84cafe8393e 100644 --- a/src/units/types.cpp +++ b/src/units/types.cpp @@ -550,9 +550,9 @@ std::vector unit_type::get_ability_list() const if (!abilities) return res; for (const config::any_child &ab : abilities.all_children_range()) { - const std::string &id = ab.cfg["id"]; + std::string id = ab.cfg["id"]; if (!id.empty()) - res.push_back(id); + res.push_back(std::move(id)); } return res;