mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-09 00:56:39 +00:00
use std::move in some places
This commit is contained in:
parent
6f021631e1
commit
daf7b90b72
@ -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"<<val<< std::endl;;
|
||||
@ -804,7 +804,7 @@ std::vector< std::string > 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 == ' ')
|
||||
|
@ -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
|
||||
|
@ -212,9 +212,9 @@ std::vector<std::string> unit::get_ability_list() const
|
||||
std::vector<std::string> 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;
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ void unit_animator::add_animation(const unit* animated_unit
|
||||
if(!tmp.animation) return;
|
||||
|
||||
start_time_ = std::max<int>(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<int>(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
|
||||
|
@ -52,12 +52,12 @@ progressive_string::progressive_string(const std::string & data,int duration) :
|
||||
std::vector<std::string> second_pass = utils::split(*tmp,':');
|
||||
if(second_pass.size() > 1) {
|
||||
try {
|
||||
data_.push_back(std::pair<std::string,int>(second_pass[0],std::stoi(second_pass[1])));
|
||||
data_.push_back(std::pair<std::string,int>(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<std::string,int>(second_pass[0],time_chunk));
|
||||
data_.push_back(std::pair<std::string,int>(std::move(second_pass[0]),time_chunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,12 +99,12 @@ progressive_image::progressive_image(const std::string & data,int duration) :
|
||||
std::vector<std::string> second_pass = utils::split(*tmp,':');
|
||||
if(second_pass.size() > 1) {
|
||||
try {
|
||||
data_.push_back(std::pair<image::locator,int>(second_pass[0],std::stoi(second_pass[1])));
|
||||
data_.push_back(std::pair<image::locator,int>(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<image::locator,int>(second_pass[0],time_chunk));
|
||||
data_.push_back(std::pair<image::locator,int>(std::move(second_pass[0]),time_chunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -550,9 +550,9 @@ std::vector<std::string> 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user