Deployed yet even more further additional emplace_back

This commit is contained in:
Charles Dang 2017-05-10 14:15:15 +11:00
parent 3ec26df495
commit e41a415588
26 changed files with 65 additions and 75 deletions

View file

@ -160,8 +160,7 @@ inline void shroud_clearer::record_sighting(
const unit & seen, const map_location & seen_loc,
size_t sighter_id, const map_location & sighter_loc)
{
sightings_.push_back(sight_data(seen.underlying_id(), seen_loc,
sighter_id, sighter_loc));
sightings_.emplace_back(seen.underlying_id(), seen_loc, sighter_id, sighter_loc);
}

View file

@ -314,7 +314,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
for(std::vector<target>::iterator tg = targets.begin(); tg != targets.end(); ++tg) {
// passing a dummy route to have the maximal rating
double max_rating = rate_target(*tg, u, dstsrc, enemy_dstsrc, dummy_route);
rated_targets.push_back( rated_target(tg, max_rating) );
rated_targets.emplace_back(tg, max_rating);
}
//use stable_sort for the moment to preserve old AI behavior
@ -563,7 +563,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
for(std::set<map_location>::const_iterator j = mass_locations.begin(); j != mass_locations.end(); ++j) {
if(*j != best_loc && distance_between(*j,best_loc) < 3) {
LOG_AI << "found mass-to-attack target... " << *j << " with value: " << value*4.0 << "\n";
targets.push_back(target(*j,value*4.0,target::TYPE::MASS));
targets.emplace_back(*j,value*4.0,target::TYPE::MASS);
best_target = targets.end() - 1;
}
}
@ -592,7 +592,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
//try to take the target
if(is_dangerous) {
LOG_AI << "found reinforcement target... " << its.first->first << " with value: " << value*2.0 << "\n";
targets.push_back(target(its.first->first,value*2.0,target::TYPE::BATTLE_AID));
targets.emplace_back(its.first->first,value*2.0,target::TYPE::BATTLE_AID);
}
best_target->value = value;
@ -618,7 +618,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
//this sounds like the road ahead might be dangerous, and that's why we don't advance.
//create this as a target, attempting to rally units around
targets.push_back(target(best->get_location(), best_target->value));
targets.emplace_back(best->get_location(), best_target->value);
best_target = targets.end() - 1;
return std::make_pair(best->get_location(), best->get_location());
}

View file

@ -64,10 +64,10 @@ inline void animated<T,T_void_value>::add_frame(int duration, const T& value,boo
{
if (frames_.empty() ) {
does_not_change_=!force_change;
frames_.push_back( frame(duration,value,starting_frame_time_));
frames_.emplace_back(duration,value,starting_frame_time_);
} else {
does_not_change_=false;
frames_.push_back( frame(duration,value,frames_.back().start_time_+frames_.back().duration_));
frames_.emplace_back(duration,value,frames_.back().start_time_+frames_.back().duration_);
}
}

View file

@ -46,7 +46,7 @@ carryover::carryover(const team& t, const int gold, const bool add)
, variables_(t.variables())
{
for(const unit_const_ptr & u : t.recall_list()) {
recall_list_.push_back(config());
recall_list_.emplace_back();
u->write(recall_list_.back());
}
}
@ -147,7 +147,7 @@ std::vector<carryover>& carryover_info::get_all_sides() {
}
void carryover_info::add_side(const config& cfg) {
carryover_sides_.push_back(carryover(cfg));
carryover_sides_.emplace_back(cfg);
}
void carryover_info::remove_side(const std::string& id) {

View file

@ -728,7 +728,7 @@ config& config::add_child(config_key_type key)
child_list& v = map_get(children, key);
v.push_back(new config());
ordered_children.push_back(child_pos(children.find(key),v.size()-1));
ordered_children.emplace_back(children.find(key),v.size()-1);
return *v.back();
}
@ -738,7 +738,7 @@ config& config::add_child(config_key_type key, const config& val)
child_list& v = map_get(children, key);
v.push_back(new config(val));
ordered_children.push_back(child_pos(children.find(key),v.size()-1));
ordered_children.emplace_back(children.find(key),v.size()-1);
return *v.back();
}
@ -748,7 +748,7 @@ config &config::add_child(config_key_type key, config &&val)
child_list &v = map_get(children, key);
v.push_back(new config(std::move(val)));
ordered_children.push_back(child_pos(children.find(key), v.size() - 1));
ordered_children.emplace_back(children.find(key), v.size() - 1);
return *v.back();
}
@ -835,7 +835,7 @@ void config::splice_children(config &src, const std::string &key)
// key might be a reference to i_src->first, so it is no longer usable.
for (unsigned j = before; j < dst.size(); ++j) {
ordered_children.push_back(child_pos(i_dst, j));
ordered_children.emplace_back(i_dst, j);
}
}

View file

@ -175,7 +175,7 @@ void display_chat_manager::add_chat_message(const time_t& time, const std::strin
int message_handle = font::add_floating_label(msg_flabel);
chat_messages_.push_back(chat_message(speaker_handle,message_handle));
chat_messages_.emplace_back(speaker_handle,message_handle);
prune_chat_messages();
}

View file

@ -33,7 +33,7 @@ map_fragment::map_fragment(const gamemap& map, const std::set<map_location>& are
void map_fragment::add_tile(const gamemap& map, const map_location& loc)
{
if (area_.find(loc) == area_.end()) {
items_.push_back(tile_info(map, loc));
items_.emplace_back(map, loc);
area_.insert(loc);
}
}

View file

@ -488,7 +488,7 @@ void wml_event_pump::raise(const std::string& event,
DBG_EH << "raising event name=" << event << ", id=" << id << "\n";
impl_->events_queue.push_back(queued_event(event, id, loc1, loc2, data));
impl_->events_queue.emplace_back(event, id, loc1, loc2, data);
}
bool wml_event_pump::operator()()

View file

@ -209,7 +209,7 @@ void cave_map_generator::cave_map_generator_job::generate_chambers()
assert(itor->second < chambers_.size());
passages_.push_back(passage(new_chamber.center, chambers_[itor->second].center, p));
passages_.emplace_back(new_chamber.center, chambers_[itor->second].center, p);
}
}
}

View file

@ -309,7 +309,7 @@ builder_multi_page::builder_multi_page(const config& cfg)
for(const auto & column : row.child_range("column"))
{
data.push_back(string_map());
data.emplace_back();
for(const auto & i : column.attribute_range())
{
data.back()[i.first] = i.second;

View file

@ -364,7 +364,7 @@ std::vector<topic> generate_time_of_day_topics(const bool /*sort_generated*/)
if (! resources::tod_manager) {
toplevel << N_("Only available during a scenario.");
topics.push_back( topic("Time of Day Schedule", "..schedule", toplevel.str()) );
topics.emplace_back("Time of Day Schedule", "..schedule", toplevel.str());
return topics;
}
const std::vector<time_of_day>& times = resources::tod_manager->times();
@ -382,10 +382,10 @@ std::vector<topic> generate_time_of_day_topics(const bool /*sort_generated*/)
"Lawful Bonus: " << time.lawful_bonus << '\n' <<
'\n' << make_link(N_("Schedule"), "..schedule");
topics.push_back( topic(time.name.str(), id, text.str()) );
topics.emplace_back(time.name.str(), id, text.str());
}
topics.push_back( topic("Time of Day Schedule", "..schedule", toplevel.str()) );
topics.emplace_back("Time of Day Schedule", "..schedule", toplevel.str());
return topics;
}
@ -478,7 +478,7 @@ std::vector<topic> generate_weapon_special_topics(const bool sort_generated)
text << font::unicode_bullet << " " << (*u) << "\n";
}
topics.push_back( topic(s->first, id, text.str()) );
topics.emplace_back(s->first, id, text.str());
}
if (sort_generated)
@ -544,7 +544,7 @@ std::vector<topic> generate_ability_topics(const bool sort_generated)
text << font::unicode_bullet << " " << (*u) << "\n";
}
topics.push_back( topic(a->first, id, text.str()) );
topics.emplace_back(a->first, id, text.str());
}
if (sort_generated)
@ -657,7 +657,7 @@ std::vector<topic> generate_faction_topics(const config & era, const bool sort_g
const std::string name = f["name"];
const std::string ref_id = faction_prefix + id;
topics.push_back( topic(name, ref_id, text.str()) );
topics.emplace_back(name, ref_id, text.str());
}
if (sort_generated)
std::sort(topics.begin(), topics.end(), title_less());
@ -713,7 +713,7 @@ std::vector<topic> generate_trait_topics(const bool sort_generated)
if (name.empty()) name = trait["female_name"].str();
if (name.empty()) name = trait["name"].str();
topics.push_back( topic(name, id, text.str()) );
topics.emplace_back(name, id, text.str());
}
if (sort_generated)
@ -961,7 +961,7 @@ std::vector<topic> generate_unit_topics(const bool sort_generated, const std::st
std::string title = additional_topic["title"];
std::string text = additional_topic["text"];
//topic additional_topic(title, id, text);
topics.push_back(topic(title,id,text));
topics.emplace_back(title,id,text);
std::string link = make_link(title, id);
race_topics.insert(link);
}
@ -990,7 +990,7 @@ std::vector<topic> generate_unit_topics(const bool sort_generated, const std::st
text << font::unicode_bullet << " " << (*u) << "\n";
}
topics.push_back(topic(race_name, race_id, text.str()) );
topics.emplace_back(race_name, race_id, text.str());
if (sort_generated)
std::sort(topics.begin(), topics.end(), title_less());
@ -1045,7 +1045,7 @@ std::string generate_contents_links(const std::string& section_name, config cons
if (config const &topic_cfg = help_cfg->find_child("topic", "id", *t)) {
std::string id = topic_cfg["id"];
if (is_visible_id(id))
topics_links.push_back(link(topic_cfg["title"], id));
topics_links.emplace_back(topic_cfg["title"], id);
}
}

View file

@ -783,7 +783,7 @@ std::string unit_topic_generator::operator()() const {
}
void unit_topic_generator::push_header(std::vector< item > &row, const std::string& name) const {
row.push_back(item(bold(name), font::line_width(name, normal_font_size, TTF_STYLE_BOLD)));
row.emplace_back(bold(name), font::line_width(name, normal_font_size, TTF_STYLE_BOLD));
}
} // end namespace help

View file

@ -99,14 +99,13 @@ bool load_language_list()
}
known_languages.clear();
known_languages.push_back(
language_def("", t_string(N_("System default language"), "wesnoth"), "ltr", "", "A"));
known_languages.emplace_back("", t_string(N_("System default language"), "wesnoth"), "ltr", "", "A");
for (const config &lang : cfg.child_range("locale"))
{
known_languages.push_back(
language_def(lang["locale"], lang["name"], lang["dir"],
lang["alternates"], lang["sort_name"]));
known_languages.emplace_back(
lang["locale"], lang["name"], lang["dir"],
lang["alternates"], lang["sort_name"]);
}
return true;

View file

@ -443,7 +443,7 @@ std::vector<map_location> gamemap::parse_location_range(const std::string &x, co
for(int x2 = xrange.first; x2 <= xrange.second; ++x2) {
for(int y2 = yrange.first; y2 <= yrange.second; ++y2) {
res.push_back(map_location(x2-1,y2-1));
res.emplace_back(x2-1,y2-1);
}
}
}

View file

@ -272,7 +272,7 @@ const teleport_map get_teleport_locations(const unit &u,
const int tunnel_count = (teleport.first)->child_count("tunnel");
for(int i = 0; i < tunnel_count; ++i) {
config teleport_group_cfg = (teleport.first)->child("tunnel", i);
groups.push_back(teleport_group(vconfig(teleport_group_cfg, true), false));
groups.emplace_back(vconfig(teleport_group_cfg, true), false);
}
}
}

View file

@ -28,7 +28,7 @@ void playturn_network_adapter::read_from_network()
{
assert(!data_.empty());
this->data_.push_back(config());
this->data_.emplace_back();
config& back = data_.back();
bool has_data = false;
try

View file

@ -328,9 +328,9 @@ void saved_game::expand_mp_events()
| boost::adaptors::transformed(modevents_entry_for("modification"))
, std::back_inserter(mods) );
if(mp_settings_.mp_era != "") //We don't want the error message below if there is no era (= if this is a sp game)
{ mods.push_back(modevents_entry("era", mp_settings_.mp_era)); }
{ mods.emplace_back("era", mp_settings_.mp_era); }
if(classification_.campaign != "")
{ mods.push_back(modevents_entry("campaign", classification_.campaign)); }
{ mods.emplace_back("campaign", classification_.campaign); }
// In the first iteration mod contains no [resource]s in all other iterations, mods contains only [resource]s
do {
@ -342,7 +342,7 @@ void saved_game::expand_mp_events()
for(const config& cfg : starting_pos_.child_range("load_resource"))
{
if(loaded_resources.find(cfg["id"].str()) == loaded_resources.end()) {
mods.push_back(modevents_entry("resource", cfg["id"].str()));
mods.emplace_back("resource", cfg["id"].str());
loaded_resources.insert(cfg["id"].str());
}
}
@ -361,9 +361,9 @@ void saved_game::expand_mp_options()
boost::copy( mp_settings_.active_mods
| boost::adaptors::transformed(modevents_entry_for("modification"))
, std::back_inserter(mods) );
mods.push_back(modevents_entry("era", mp_settings_.mp_era));
mods.push_back(modevents_entry("multiplayer", get_scenario_id()));
mods.push_back(modevents_entry("campaign", classification().campaign));
mods.emplace_back("era", mp_settings_.mp_era);
mods.emplace_back("multiplayer", get_scenario_id());
mods.emplace_back("campaign", classification().campaign);
config& variables = carryover_.child_or_add("variables");
for(modevents_entry& mod : mods)

View file

@ -229,17 +229,13 @@ void schema_validator::validate(const config & cfg, const std::string & name,
tag != p.second ; ++tag){
int cnt = counter_.top()[tag->first].cnt;
if (tag->second.get_min() > cnt){
cache_.top()[&cfg].push_back(
message_info(MISSING_TAG,file,start_line,
tag->second.get_min(),tag->first,"",
name));
cache_.top()[&cfg].emplace_back(
MISSING_TAG,file,start_line,tag->second.get_min(),tag->first,"",name);
continue;
}
if (tag->second.get_max() < cnt){
cache_.top()[&cfg].push_back(
message_info(EXTRA_TAG,file,start_line,
tag->second.get_max(),tag->first,"",
name));
cache_.top()[&cfg].emplace_back(
EXTRA_TAG,file,start_line,tag->second.get_max(),tag->first,"",name);
}
}
// Checking if all mandatory keys are present
@ -248,9 +244,8 @@ void schema_validator::validate(const config & cfg, const std::string & name,
key != k.second ; ++key){
if (key->second.is_mandatory()){
if (cfg.get(key->first) == nullptr){
cache_.top()[&cfg].push_back(
message_info(MISSING_KEY,file,start_line,0,
name,key->first ));
cache_.top()[&cfg].emplace_back(
MISSING_KEY,file,start_line,0,name,key->first );
}
}
}
@ -273,17 +268,14 @@ void schema_validator::validate_key(const config & cfg,
boost::smatch sub;
bool res = boost::regex_match(value,sub,itt->second);
if (!res ) {
cache_.top()[&cfg].push_back(
message_info(WRONG_VALUE,file,start_line,0,
stack_.top()->get_name(),
name,value));
cache_.top()[&cfg].emplace_back(
WRONG_VALUE,file,start_line,0,stack_.top()->get_name(),name,value);
}
}
}
else{
cache_.top()[&cfg].push_back(
message_info(EXTRA_KEY,file,start_line,0,
stack_.top()->get_name(),name));
cache_.top()[&cfg].emplace_back(
EXTRA_KEY,file,start_line,0, stack_.top()->get_name(),name);
}
}

View file

@ -264,7 +264,7 @@ node::node(document& doc, node* parent, const char** str, int depth) :
s = end + 1;
children_[list_index].second.push_back(new node(doc, this, str, depth+1));
ordered_children_.push_back(node_pos(list_index, children_[list_index].second.size() - 1));
ordered_children_.emplace_back(list_index, children_[list_index].second.size() - 1);
check_ordered_children();
break;
@ -357,7 +357,7 @@ node::node(document& doc, node* parent, const char** str, int depth) :
s = end + 1;
attr_.push_back(attribute(name, value));
attr_.emplace_back(name, value);
}
}
}
@ -475,7 +475,7 @@ node& node::add_child(const char* name)
check_ordered_children();
child_list& list = children_[list_index].second;
list.push_back(new node(*doc_, this));
ordered_children_.push_back(node_pos(list_index, list.size() - 1));
ordered_children_.emplace_back(list_index, list.size() - 1);
check_ordered_children();
return *list.back();
}
@ -524,7 +524,7 @@ void node::insert_ordered_child(int child_map_index, int child_list_index)
}
if(!inserted) {
ordered_children_.push_back(node_pos(child_map_index, child_list_index));
ordered_children_.emplace_back(child_map_index, child_list_index);
}
}
@ -661,7 +661,7 @@ int node::get_children(const string_span& name)
}
}
children_.push_back(child_pair(string_span(name), child_list()));
children_.emplace_back(string_span(name), child_list());
return children_.size() - 1;
}

View file

@ -748,7 +748,7 @@ terrain_builder::terrain_constraint& terrain_builder::add_constraints(terrain_bu
if(!cons) {
// The terrain at the current location did not exist, so create it
constraints.push_back(terrain_constraint(loc));
constraints.emplace_back(loc);
cons = &constraints.back();
}

View file

@ -344,7 +344,7 @@ const std::set<map_location>& tod_manager::get_area_by_index(int index) const
void tod_manager::add_time_area(const gamemap & map, const config& cfg)
{
areas_.push_back(area_time_of_day());
areas_.emplace_back();
area_time_of_day &area = areas_.back();
area.id = cfg["id"].str();
area.xsrc = cfg["x"].str();
@ -359,7 +359,7 @@ void tod_manager::add_time_area(const gamemap & map, const config& cfg)
void tod_manager::add_time_area(const std::string& id, const std::set<map_location>& locs,
const config& time_cfg)
{
areas_.push_back(area_time_of_day());
areas_.emplace_back();
area_time_of_day& area = areas_.back();
area.id = id;
area.hexes = locs;

View file

@ -140,7 +140,7 @@ public:
if(type.parse(cond_name)) {
const vconfig& cond_filter = cond.get_child();
cond_children_.push_back(unit_filter(cond_filter, &fc_, use_flat_tod_));
cond_children_.emplace_back(cond_filter, &fc_, use_flat_tod_);
cond_child_types_.push_back(type);
}
else {

View file

@ -595,7 +595,7 @@ void unit_type::add_advancement(const unit_type &to_unit,int xp)
// Add advancements to gendered subtypes, if supported by to_unit
for(int gender=0; gender<=1; ++gender) {
if(!gender_types_[gender]) {
if(!gender_types_[gender]) {
continue;
}
if(!to_unit.gender_types_[gender]) {

View file

@ -190,7 +190,7 @@ void wesnothd_connection::handle_read(
if(ec && ec != boost::asio::error::eof)
throw system_error(ec);
std::istream is(&read_buf_);
recv_queue_.push_back(config());
recv_queue_.emplace_back();
read_gz(recv_queue_.back(), is);
DBG_NW << "Received " << recv_queue_.back() << " bytes.\n";

View file

@ -111,7 +111,7 @@ move::move(config const& cfg, bool hidden)
throw action::ctor_err("move: Invalid route_");
route_->move_cost = route_cfg["move_cost"];
for(config const& loc_cfg : route_cfg.child_range("step")) {
route_->steps.push_back(map_location(loc_cfg["x"],loc_cfg["y"], wml_loc()));
route_->steps.emplace_back(loc_cfg["x"],loc_cfg["y"], wml_loc());
}
for(config const& mark_cfg : route_cfg.child_range("mark")) {
route_->marks[map_location(mark_cfg["x"],mark_cfg["y"], wml_loc())]

View file

@ -106,7 +106,7 @@ const SDL_Rect* widget::clip_rect() const
void widget::bg_register(SDL_Rect const &rect)
{
restorer_.push_back(surface_restorer(&video(), rect));
restorer_.emplace_back(&video(), rect);
}
void widget::set_location(int x, int y)