Deployed std::map::emplace en-masse
This commit is contained in:
parent
76f92a205f
commit
e1a579da51
21 changed files with 42 additions and 46 deletions
|
@ -400,9 +400,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
|
|||
* and calculate_possible_moves() become redundant, and one of
|
||||
* them should probably be eliminated.
|
||||
*/
|
||||
res.insert(std::pair<map_location,pathfind::paths>(
|
||||
un_it->get_location(), pathfind::paths(
|
||||
*un_it, false, true, current_team(), 0, see_all)));
|
||||
res.emplace(un_it->get_location(), pathfind::paths(*un_it, false, true, current_team(), 0, see_all));
|
||||
}
|
||||
|
||||
// deactivate terrain filtering if it's just the dummy 'matches nothing'
|
||||
|
@ -442,8 +440,8 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
|
|||
}
|
||||
|
||||
if(src != dst && (resources::gameboard->find_visible_unit(dst, current_team()) == resources::gameboard->units().end()) ) {
|
||||
srcdst.insert(std::pair<map_location,map_location>(src,dst));
|
||||
dstsrc.insert(std::pair<map_location,map_location>(dst,src));
|
||||
srcdst.emplace(src, dst);
|
||||
dstsrc.emplace(dst, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -515,7 +513,7 @@ const defensive_position& readonly_context_impl::best_defensive_position(const m
|
|||
}
|
||||
}
|
||||
|
||||
defensive_position_cache_.insert(std::pair<map_location,defensive_position>(loc,pos));
|
||||
defensive_position_cache_.emplace(loc, pos);
|
||||
return defensive_position_cache_[loc];
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ double move_leader_to_goals_phase::evaluate()
|
|||
const pathfind::paths leader_paths(*leader, false, true, current_team());
|
||||
|
||||
std::map<map_location,pathfind::paths> possible_moves;
|
||||
possible_moves.insert(std::pair<map_location,pathfind::paths>(leader->get_location(), leader_paths));
|
||||
possible_moves.emplace(leader->get_location(), leader_paths);
|
||||
|
||||
map_location loc;
|
||||
for (const map_location &l : route.steps)
|
||||
|
@ -720,7 +720,7 @@ void get_villages_phase::find_villages(
|
|||
threat = vuln->second;
|
||||
} else {
|
||||
threat = power_projection(current_loc,enemy_dstsrc);
|
||||
vulnerability.insert(std::pair<map_location,double>(current_loc,threat));
|
||||
vulnerability.emplace(current_loc, threat);
|
||||
}
|
||||
|
||||
const unit_map::const_iterator u = resources::gameboard->units().find(j->second);
|
||||
|
|
|
@ -308,12 +308,11 @@ void map_context::load_scenario(const config& game_config)
|
|||
|
||||
for(const config& item : scenario.child_range("item")) {
|
||||
const map_location loc(item);
|
||||
overlays_.insert(std::pair<map_location,
|
||||
overlay>(loc, overlay(item) ));
|
||||
overlays_.emplace(loc, overlay(item));
|
||||
}
|
||||
|
||||
for(const config& music : scenario.child_range("music")) {
|
||||
music_tracks_.insert(std::pair<std::string, sound::music_track>(music["name"], sound::music_track(music)));
|
||||
music_tracks_.emplace(music["name"], sound::music_track(music));
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
|
|
|
@ -207,7 +207,7 @@ public:
|
|||
void add_to_playlist(const sound::music_track& track) {
|
||||
|
||||
if (music_tracks_.find(track.id()) == music_tracks_.end())
|
||||
music_tracks_.insert(std::pair<std::string, sound::music_track>(track.id(), track));
|
||||
music_tracks_.emplace(track.id(), track);
|
||||
else music_tracks_.erase(track.id());
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void item_palette::setup(const config& cfg)
|
|||
|
||||
for (const config& item : group.child_range("item")) {
|
||||
|
||||
item_map_.insert(std::pair<std::string, overlay>(item["id"], overlay(item)));
|
||||
item_map_.emplace(item["id"], overlay(item));
|
||||
group_map_[group["id"]].push_back(item["id"]);
|
||||
if (!group["core"].to_bool(false))
|
||||
non_core_items_.insert(item["id"]);
|
||||
|
|
|
@ -37,7 +37,7 @@ void unit_palette::setup(const config& /*cfg*/)
|
|||
{
|
||||
if (i.second.do_not_list())
|
||||
continue;
|
||||
item_map_.insert(std::pair<std::string, unit_type>(i.second.id(), i.second));
|
||||
item_map_.emplace(i.second.id(), i.second);
|
||||
group_map_[i.second.race_id()].push_back(i.second.id());
|
||||
nmax_items_ = std::max<int>(nmax_items_, group_map_[i.second.race_id()].size());
|
||||
//TODO
|
||||
|
|
|
@ -201,7 +201,7 @@ int add_floating_label(const floating_label& flabel)
|
|||
}
|
||||
|
||||
++label_id;
|
||||
labels.insert(std::pair<int, floating_label>(label_id, flabel));
|
||||
labels.emplace(label_id, flabel);
|
||||
label_contexts.top().insert(label_id);
|
||||
return label_id;
|
||||
}
|
||||
|
|
|
@ -436,7 +436,7 @@ SDL_Rect line_size(const std::string& line, int font_size, int style)
|
|||
res.h = s.height();
|
||||
res.x = res.y = 0;
|
||||
|
||||
cache.insert(std::pair<std::string,SDL_Rect>(line,res));
|
||||
cache.emplace(line,res);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ std::multimap<std::string, config> side_engine::get_side_children()
|
|||
|
||||
for(const std::string& children_to_swap : get_children_to_swap()) {
|
||||
for(const config& child : cfg_.child_range(children_to_swap)) {
|
||||
children.insert(std::pair<std::string, config>(children_to_swap, child));
|
||||
children.emplace(children_to_swap, child);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace {
|
|||
res = child["cost"].to_double();
|
||||
}
|
||||
|
||||
cache_.insert(std::pair<t_translation::terrain_code, double>(c,res));
|
||||
cache_.emplace(c, res);
|
||||
return windiness*res;
|
||||
}
|
||||
|
||||
|
@ -685,10 +685,10 @@ static void flood_name(const map_location& start, const std::string& name, std::
|
|||
const t_translation::terrain_code terr = terrain[adj[n].x + (width / 3)][adj[n].y + (height / 3)];
|
||||
const map_location loc(adj[n].x, adj[n].y);
|
||||
if((t_translation::terrain_matches(terr, tile_types)) && (tile_names.find(loc) == tile_names.end())) {
|
||||
tile_names.insert(std::pair<map_location, std::string>(loc, name));
|
||||
tile_names.emplace(loc, name);
|
||||
//labeling decision: this is result of trial and error on what looks best in game
|
||||
if(label_count % 6 == 0) { //ensure that labels do not occur more often than every 6 recursions
|
||||
labels->insert(std::pair<map_location, std::string>(loc, full_name));
|
||||
labels->emplace(loc, full_name);
|
||||
label_count++; //ensure that no adjacent tiles get labeled
|
||||
}
|
||||
flood_name(adj[n], name, tile_names, tile_types, terrain, width, height, label_count++, labels, full_name);
|
||||
|
@ -823,10 +823,10 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
const map_location loc(r->x-data.width/3,r->y-data.height/3);
|
||||
|
||||
if(((r - river.begin())%name_frequency) == name_frequency/2) {
|
||||
misc_labels->insert(std::pair<map_location,std::string>(loc,name));
|
||||
misc_labels->emplace(loc, name);
|
||||
}
|
||||
|
||||
river_names.insert(std::pair<map_location,std::string>(loc,base_name));
|
||||
river_names.emplace(loc, base_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,12 +859,12 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
if(!touches_other_lake) {
|
||||
const map_location loc(x-data.width/3,y-data.height/3);
|
||||
misc_labels->erase(loc);
|
||||
misc_labels->insert(std::pair<map_location,std::string>(loc,name));
|
||||
misc_labels->emplace(loc, name);
|
||||
}
|
||||
|
||||
for(auto i : locs) {
|
||||
const map_location loc(i.x-data.width/3,i.y-data.height/3);
|
||||
lake_names.insert(std::pair<map_location, std::string>(loc, base_name));
|
||||
lake_names.emplace(loc, base_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1099,8 +1099,8 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
std::string bridge_base_name = base_name_generator->generate();
|
||||
const std::string& name = bridge_name_generator->generate({{"base", bridge_base_name}});
|
||||
const map_location loc(x - data.width / 3, y-data.height/3);
|
||||
misc_labels->insert(std::pair<map_location,std::string>(loc,name));
|
||||
bridge_names.insert(std::pair<map_location,std::string>(loc, bridge_base_name)); //add to use for village naming
|
||||
misc_labels->emplace(loc, name);
|
||||
bridge_names.emplace(loc, bridge_base_name); //add to use for village naming
|
||||
bridges.insert(loc);
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1121,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
if(!convert_to.empty()) {
|
||||
const t_translation::terrain_code letter = t_translation::read_terrain_code(convert_to);
|
||||
if(misc_labels != nullptr && terrain[x][y] != letter && name_count++ == name_frequency && !on_bridge) {
|
||||
misc_labels->insert(std::pair<map_location,std::string>(map_location(x-data.width/3,y-data.height/3),road_name));
|
||||
misc_labels->emplace(map_location(x - data.width / 3, y - data.height / 3), road_name);
|
||||
name_count = 0;
|
||||
}
|
||||
|
||||
|
@ -1129,7 +1129,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
if(misc_labels != nullptr) {
|
||||
const map_location loc(x - data.width / 3, y - data.height / 3); //add to use for village naming
|
||||
if(road_base_name != "")
|
||||
road_names.insert(std::pair<map_location,std::string>(loc, road_base_name));
|
||||
road_names.emplace(loc, road_base_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1189,8 +1189,8 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
base_name = base_name_generator->generate();
|
||||
name = mountain_name_generator->generate({{"base", base_name}});
|
||||
}
|
||||
misc_labels->insert(std::pair<map_location, std::string>(loc, name));
|
||||
mountain_names.insert(std::pair<map_location, std::string>(loc, base_name));
|
||||
misc_labels->emplace(loc, name);
|
||||
mountain_names.emplace(loc, base_name);
|
||||
}
|
||||
} else if(t_translation::terrain_matches(terr, t_translation::ALL_FORESTS)) {
|
||||
// If the forest tile is not named yet, name it
|
||||
|
@ -1200,7 +1200,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
base_name = base_name_generator->generate();
|
||||
name = forest_name_generator->generate({{"base", base_name}});
|
||||
}
|
||||
forest_names.insert(std::pair<map_location, std::string>(loc, base_name));
|
||||
forest_names.emplace(loc, base_name);
|
||||
// name all connected forest tiles accordingly
|
||||
flood_name(loc, base_name, forest_names, t_translation::ALL_FORESTS, terrain, data.width, data.height, 0, misc_labels, name);
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
base_name = base_name_generator->generate();
|
||||
name = swamp_name_generator->generate({{"base", base_name}});
|
||||
}
|
||||
swamp_names.insert(std::pair<map_location, std::string>(loc, base_name));
|
||||
swamp_names.emplace(loc, base_name);
|
||||
// name all connected swamp tiles accordingly
|
||||
flood_name(loc, base_name, swamp_names, t_translation::ALL_SWAMPS, terrain, data.width, data.height, 0, misc_labels, name);
|
||||
}
|
||||
|
@ -1404,7 +1404,7 @@ std::string default_map_generator_job::default_generate_map(generator_data data,
|
|||
}
|
||||
|
||||
used_names.insert(name);
|
||||
village_labels->insert(std::pair<map_location,std::string>(loc,name));
|
||||
village_labels->emplace(loc, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ int halo_impl::add(int x, int y, const std::string& image, const map_location& l
|
|||
image_vector.push_back(animated<image::locator>::frame_description(time,image::locator(str)));
|
||||
|
||||
}
|
||||
haloes.insert(std::pair<int,effect>(id,effect(disp,x,y,image_vector,loc,orientation,infinite)));
|
||||
haloes.emplace(id, effect(disp, x, y, image_vector, loc, orientation, infinite));
|
||||
new_haloes.insert(id);
|
||||
if(haloes.find(id)->second.does_change() || !infinite) {
|
||||
changing_haloes.insert(id);
|
||||
|
|
|
@ -1069,7 +1069,7 @@ surface reverse_image(const surface& surf)
|
|||
return surface(nullptr);
|
||||
}
|
||||
|
||||
reversed_images_.insert(std::pair<surface,surface>(surf,rev));
|
||||
reversed_images_.emplace(surf, rev);
|
||||
// sdl_add_ref(rev);
|
||||
return rev;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ void class_tag::add_link(const std::string &link){
|
|||
std::string::size_type pos_last = link.rfind('/');
|
||||
//if (pos_last == std::string::npos) return;
|
||||
std::string name_link = link.substr(pos_last+1,link.length());
|
||||
links_.insert(std::pair<std::string,std::string>(name_link,link));
|
||||
links_.emplace(name_link, link);
|
||||
}
|
||||
|
||||
const class_key * class_tag::find_key(const std::string &name) const{
|
||||
|
|
|
@ -40,7 +40,7 @@ suh::suh(config c)
|
|||
void suh::add_user(const std::string& name, const std::string& mail, const std::string& password) {
|
||||
if(user_exists(name)) throw error("This nickname is already registered");
|
||||
|
||||
users_.insert(std::pair<std::string, user>(name, user()));
|
||||
users_.emplace(name, user());
|
||||
|
||||
set_password(name, password);
|
||||
set_mail(name, mail);
|
||||
|
|
|
@ -267,7 +267,7 @@ static std::string pick_one(const std::string &files)
|
|||
prev_choices[files] = choice;
|
||||
} else {
|
||||
choice = rand()%ids.size();
|
||||
prev_choices.insert(std::pair<std::string,unsigned int>(files,choice));
|
||||
prev_choices.emplace(files,choice);
|
||||
}
|
||||
|
||||
return ids[choice];
|
||||
|
|
|
@ -823,7 +823,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
|
|||
// Dots are simple placeholders,
|
||||
// which do not represent actual terrains.
|
||||
} else if (terrain.overlay != 0 ) {
|
||||
anchors.insert(std::pair<int, map_location>(terrain.overlay, map_location(x, y)));
|
||||
anchors.emplace(terrain.overlay, map_location(x, y));
|
||||
} else if (terrain.base == t_translation::TB_STAR) {
|
||||
add_constraints(br.constraints, map_location(x, y), t_translation::STAR, global_images);
|
||||
} else {
|
||||
|
|
|
@ -165,8 +165,7 @@ bool terrain_type_data::try_merge_terrains(const t_translation::terrain_code & t
|
|||
|
||||
terrain_type new_terrain(base_iter->second, overlay_iter->second);
|
||||
terrainList_.push_back(new_terrain.number());
|
||||
tcodeToTerrain_.insert(std::pair<t_translation::terrain_code, terrain_type>(
|
||||
new_terrain.number(), new_terrain));
|
||||
tcodeToTerrain_.emplace(new_terrain.number(), new_terrain);
|
||||
return true;
|
||||
}
|
||||
return true; // Terrain already exists, nothing to do
|
||||
|
|
|
@ -715,7 +715,7 @@ void theme::add_object(const config& cfg)
|
|||
if (const config &status_cfg = cfg.child("status"))
|
||||
{
|
||||
for(const config::any_child &i : status_cfg.all_children_range()) {
|
||||
status_.insert(std::pair<std::string, status_item>(i.key, status_item(i.cfg)));
|
||||
status_.emplace(i.key, status_item(i.cfg));
|
||||
}
|
||||
if (const config &unit_image_cfg = status_cfg.child("unit_image")) {
|
||||
unit_image_ = object(unit_image_cfg);
|
||||
|
|
|
@ -443,7 +443,7 @@ const SDL_Rect& unit_drawer::calculate_energy_bar(surface surf) const
|
|||
, first_row
|
||||
, last_col-first_col
|
||||
, last_row+1-first_row);
|
||||
energy_bar_rects_.insert(std::pair<surface,SDL_Rect>(surf,res));
|
||||
energy_bar_rects_.emplace(surf, res);
|
||||
return calculate_energy_bar(surf);
|
||||
}
|
||||
|
||||
|
|
|
@ -1024,7 +1024,7 @@ void unit_type_data::set_config(config &cfg)
|
|||
for (const config &r : cfg.child_range("race"))
|
||||
{
|
||||
const unit_race race(r);
|
||||
races_.insert(std::pair<std::string,unit_race>(race.id(),race));
|
||||
races_.emplace(race.id(), race);
|
||||
gui2::dialogs::loading_screen::progress();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ menu::basic_sorter& menu::basic_sorter::set_id_sort(int column)
|
|||
menu::basic_sorter& menu::basic_sorter::set_redirect_sort(int column, int to)
|
||||
{
|
||||
if(column != to) {
|
||||
redirect_sort_.insert(std::pair<int,int>(column,to));
|
||||
redirect_sort_.emplace(column, to);
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -1155,7 +1155,7 @@ SDL_Rect menu::get_item_rect_internal(size_t item) const
|
|||
//only insert into the cache if the menu's co-ordinates have
|
||||
//been initialized
|
||||
if (loc.x > 0 && loc.y > 0)
|
||||
itemRects_.insert(std::pair<int,SDL_Rect>(item,res));
|
||||
itemRects_.emplace(item, res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue