Skip to content

Commit

Permalink
Cleaned up unnecessary instances of emplace_back(config {})
Browse files Browse the repository at this point in the history
No need to invoke the copy ctor.
  • Loading branch information
Vultraz authored and gfgtdf committed Oct 7, 2018
1 parent ea611b5 commit fc6ff0c
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/controller_base.cpp
Expand Up @@ -450,7 +450,7 @@ void controller_base::show_menu(
const hotkey::hotkey_command& command = hotkey::get_hotkey_command(id);

if(cmd_exec->can_execute_command(command) && (!context_menu || in_context_menu(command.id))) {
items.emplace_back(config{"id", id});
items.emplace_back("id", id);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/editor/controller/editor_controller.cpp
Expand Up @@ -651,7 +651,7 @@ bool editor_controller::do_execute_command(const hotkey::hotkey_command& cmd, in
sound::play_music_once(music_tracks_[index].id());
get_current_map_context().add_to_playlist(music_tracks_[index]);
std::vector<config> items;
items.emplace_back(config {"id", "editor-playlist"});
items.emplace_back("id", "editor-playlist");
std::shared_ptr<gui::button> b = gui_->find_menu_button("menu-playlist");
show_menu(items, b->location().x +1, b->location().y + b->height() +1, false, *gui_);
return true;
Expand Down Expand Up @@ -1020,7 +1020,7 @@ void editor_controller::show_menu(const std::vector<config>& items_arg, int xloc
if((can_execute_command(command) && (!context_menu || in_context_menu(command.id)))
|| command.id == hotkey::HOTKEY_NULL)
{
items.emplace_back(config {"id", id});
items.emplace_back("id", id);
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/editor/map/context_manager.cpp
Expand Up @@ -326,7 +326,7 @@ void context_manager::expand_open_maps_menu(std::vector<config>& items, int i)
const std::string label = ss.str();
const std::string details = get_menu_marker(changed);

contexts.emplace_back(config {"label", label, "details", details});
contexts.emplace_back("label", label, "details", details);
}

items.insert(pos, contexts.begin(), contexts.end());
Expand Down Expand Up @@ -389,7 +389,7 @@ void context_manager::expand_areas_menu(std::vector<config>& items, int i)
const std::string label = ss.str();
const std::string details = get_menu_marker(changed);

area_entries.emplace_back(config {"label", label, "details", details});
area_entries.emplace_back("label", label, "details", details);
}

items.insert(pos, area_entries.begin(), area_entries.end());
Expand All @@ -413,7 +413,7 @@ void context_manager::expand_sides_menu(std::vector<config>& items, int i)
label << teamname;
}

contexts.emplace_back(config {"label", label.str()});
contexts.emplace_back("label", label.str());
}

items.insert(pos, contexts.begin(), contexts.end());
Expand All @@ -429,10 +429,10 @@ void context_manager::expand_time_menu(std::vector<config>& items, int i)
assert(tod_m != nullptr);

for(const time_of_day& time : tod_m->times()) {
times.emplace_back(config {
times.emplace_back(
"details", time.name, // Use 'details' field here since the image will take the first column
"image", time.image,
});
"image", time.image
);
}

items.insert(pos, times.begin(), times.end());
Expand All @@ -446,10 +446,10 @@ void context_manager::expand_local_time_menu(std::vector<config>& items, int i)
tod_manager* tod_m = get_map_context().get_time_manager();

for(const time_of_day& time : tod_m->times(get_map_context().get_active_area())) {
times.emplace_back(config {
times.emplace_back(
"details", time.name, // Use 'details' field here since the image will take the first column
"image", time.image,
});
"image", time.image
);
}

items.insert(pos, times.begin(), times.end());
Expand Down
6 changes: 3 additions & 3 deletions src/editor/palette/editor_palettes.cpp
Expand Up @@ -62,10 +62,10 @@ void editor_palette<Item>::expand_palette_groups_menu(std::vector<config>& items
img += ".png";
}

groups.emplace_back(config {
groups.emplace_back(
"label", groupname,
"icon", img,
});
"icon", img
);
}

items.insert(pos, groups.begin(), groups.end());
Expand Down
2 changes: 1 addition & 1 deletion src/game_events/action_wml.cpp
Expand Up @@ -711,7 +711,7 @@ WML_HANDLER_FUNCTION(set_variables,, cfg)

for(std::vector<std::string>::iterator i=split_vector.begin(); i!=split_vector.end(); ++i)
{
data.emplace_back(config {key_name, *i});
data.emplace_back(key_name, *i);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game_events/wmi_manager.cpp
Expand Up @@ -130,7 +130,7 @@ void wmi_manager::get_items(const map_location& hex,
&& item->can_show(hex, gamedata, fc)) {
// Include this item.
items.push_back(item);
descriptions.emplace_back(config {"id", item->menu_text()});
descriptions.emplace_back("id", item->menu_text());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/dialogs/addon/manager.cpp
Expand Up @@ -334,7 +334,7 @@ void addon_manager::pre_show(window& window)

std::vector<config> status_filter_entries;
for(const auto& f : status_filter_types_) {
status_filter_entries.emplace_back(config {"label", t_string(f.second, GETTEXT_DOMAIN)});
status_filter_entries.emplace_back("label", t_string(f.second, GETTEXT_DOMAIN));
}

status_filter.set_values(status_filter_entries);
Expand All @@ -346,7 +346,7 @@ void addon_manager::pre_show(window& window)

std::vector<config> type_filter_entries;
for(const auto& f : type_filter_types_) {
type_filter_entries.emplace_back(config {"label", t_string(f.second, GETTEXT_DOMAIN), "checkbox", false});
type_filter_entries.emplace_back("label", t_string(f.second, GETTEXT_DOMAIN), "checkbox", false);
}

type_filter.set_values(type_filter_entries);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/dialogs/campaign_selection.cpp
Expand Up @@ -260,7 +260,7 @@ void campaign_selection::pre_show(window& window)
for(const auto& mod : engine_.get_const_extras_by_type(ng::create_engine::MOD)) {
const bool active = std::find(enabled.begin(), enabled.end(), mod->id) != enabled.end();

mod_menu_values.emplace_back(config {"label", mod->name, "checkbox", active});
mod_menu_values.emplace_back("label", mod->name, "checkbox", active);

mod_states_.push_back(active);
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/dialogs/multiplayer/faction_select.cpp
Expand Up @@ -157,13 +157,13 @@ void faction_select::on_faction_select(window& window)

if(unit) {
const std::string icon = formatter() << unit->image() << "~RC(" << unit->flag_rgb() << ">" << tc_color_ << ")";
leaders.emplace_back(config {"label", unit->type_name(), "icon", icon});
leaders.emplace_back("label", unit->type_name(), "icon", icon);
} else if(leader == "random") {
leaders.emplace_back(config {"label", _("Random"), "icon", ng::random_enemy_picture});
leaders.emplace_back("label", _("Random"), "icon", ng::random_enemy_picture);
} else if(leader == "null") {
leaders.emplace_back(config {"label", font::unicode_em_dash});
leaders.emplace_back("label", font::unicode_em_dash);
} else {
leaders.emplace_back(config {"label", "?"});
leaders.emplace_back("label", "?");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/gui/dialogs/multiplayer/mp_create_game.cpp
Expand Up @@ -181,7 +181,7 @@ void mp_create_game::pre_show(window& win)
//
std::vector<config> game_types;
for(level_type_info& type_info : level_types_) {
game_types.emplace_back(config {"label", type_info.second});
game_types.emplace_back("label", type_info.second);
}

if(game_types.empty()) {
Expand Down Expand Up @@ -249,7 +249,7 @@ void mp_create_game::pre_show(window& win)

std::vector<config> era_names;
for(const auto& era : create_engine_.get_const_extras_by_type(ng::create_engine::ERA)) {
era_names.emplace_back(config {"label", era->name, "tooltip", era->description});
era_names.emplace_back("label", era->name, "tooltip", era->description);
}

if(era_names.empty()) {
Expand Down
12 changes: 6 additions & 6 deletions src/gui/dialogs/multiplayer/mp_staging.cpp
Expand Up @@ -202,7 +202,7 @@ void mp_staging::add_side_node(window& window, ng::side_engine_ptr side)
// We use an index-based loop in order to get the index of the selected option
std::vector<config> ai_options;
for(unsigned i = 0; i < ai_algorithms_.size(); ++i) {
ai_options.emplace_back(config {"label", ai_algorithms_[i]->text});
ai_options.emplace_back("label", ai_algorithms_[i]->text);

if(ai_algorithms_[i]->id == side->ai_algorithm()) {
selection = i;
Expand All @@ -223,7 +223,7 @@ void mp_staging::add_side_node(window& window, ng::side_engine_ptr side)
//
std::vector<config> controller_names;
for(const auto& controller : side->controller_options()) {
controller_names.emplace_back(config {"label", controller.second});
controller_names.emplace_back("label", controller.second);
}

menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
Expand Down Expand Up @@ -290,10 +290,10 @@ void mp_staging::add_side_node(window& window, ng::side_engine_ptr side)
//
std::vector<config> color_options;
for(const auto& color : side->color_options()) {
color_options.emplace_back(config {
color_options.emplace_back(
"label", font::get_color_string_pango(color),
"icon", (formatter() << "misc/status.png~RC(magenta>" << color << ")").str(),
});
"icon", (formatter() << "misc/status.png~RC(magenta>" << color << ")").str()
);
}

menu_button& color_selection = find_widget<menu_button>(&row_grid, "side_color", false);
Expand Down Expand Up @@ -509,7 +509,7 @@ void mp_staging::network_handler(window& window)

std::vector<config> controller_names;
for(const auto& controller : side->controller_options()) {
controller_names.emplace_back(config {"label", controller.second});
controller_names.emplace_back("label", controller.second);
}

menu_button& controller_selection = find_widget<menu_button>(&row_grid, "controller", false);
Expand Down
6 changes: 3 additions & 3 deletions src/hotkey/hotkey_handler.cpp
Expand Up @@ -410,13 +410,13 @@ void play_controller::hotkey_handler::expand_autosaves(std::vector<config>& item

if(savegame::save_game_exists(name, comp_format)) {
newsaves.emplace_back(name + compression::format_extension(comp_format));
newitems.emplace_back(config {"label", _("Back to Turn ") + std::to_string(turn)});
newitems.emplace_back("label", _("Back to Turn ") + std::to_string(turn));
}
}

if(savegame::save_game_exists(start_name, comp_format)) {
newsaves.emplace_back(start_name + compression::format_extension(comp_format));
newitems.emplace_back(config {"label", _("Back to Start")});
newitems.emplace_back("label", _("Back to Start"));
}

// Make sure list doesn't get too long: keep top two, midpoint and bottom.
Expand Down Expand Up @@ -455,7 +455,7 @@ void play_controller::hotkey_handler::show_menu(const std::vector<config>& items
const hotkey::hotkey_command& command = hotkey::get_hotkey_command(id);

if(id == "wml" || (can_execute_command(command) && (!context_menu || in_context_menu(command.id)))) {
items.emplace_back(config {"id", id});
items.emplace_back("id", id);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/theme.cpp
Expand Up @@ -521,7 +521,7 @@ theme::menu::menu(const config& cfg)
, items_()
{
for(const auto& item : utils::split(cfg["items"])) {
items_.emplace_back(config {"id", item});
items_.emplace_back("id", item);
}

if(cfg["auto_tooltip"].to_bool() && tooltip_.empty() && items_.size() == 1) {
Expand Down

0 comments on commit fc6ff0c

Please sign in to comment.