Skip to content

Commit

Permalink
Avoid unnecessary copy construction [performance-unnecessary-copy-ini…
Browse files Browse the repository at this point in the history
…tialization]
  • Loading branch information
BrettDong committed Mar 30, 2023
1 parent 8f94505 commit 10bac1e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/advanced_inv_pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void advanced_inventory_pane::load_settings( int saved_area_idx,
!is_re_enter ) ? saved_area_idx :
save_state->area_idx;
const aim_location location = static_cast<aim_location>( i_location );
const advanced_inv_area square = squares[location];
const advanced_inv_area &square = squares[location];
// determine the square's vehicle/map item presence
bool has_veh_items = square.can_store_in_vehicle() ?
!square.veh->get_items( square.vstor ).empty() : false;
Expand Down
2 changes: 1 addition & 1 deletion src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ void construct::done_appliance( const tripoint_bub_ms &p, Character & )
return;
}

const item base = components.front();
const item &base = components.front();
const vpart_id &vpart = vpart_appliance_from_item( base.typeId() );

// TODO: fix point types
Expand Down
2 changes: 1 addition & 1 deletion src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ std::pair<nutrients, nutrients> Character::compute_nutrient_range(
our_extra_flags.insert( flag_COOKED );
}

const requirement_data requirements = rec.simple_requirements();
const requirement_data &requirements = rec.simple_requirements();
const requirement_data::alter_item_comp_vector &component_requirements =
requirements.get_components();

Expand Down
2 changes: 1 addition & 1 deletion src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ std::string trim_by_length( const std::string &text, int width )

const std::vector<std::string> color_segments = split_by_color( text );
for( size_t i = 0; i < color_segments.size() ; ++i ) {
std::string seg = color_segments[i];
const std::string &seg = color_segments[i];
if( seg.empty() ) {
// TODO: Check is required right now because, for a fully-color-tagged string, split_by_color
// returns an empty string first
Expand Down
2 changes: 1 addition & 1 deletion src/sdltiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ std::string cata_tiles::get_omt_id_rotation_and_subtile(
oter_id ot_id = oter_at( omp );
const oter_t &ot = *ot_id;
oter_type_id ot_type_id = ot.get_type_id();
oter_type_t ot_type = *ot_type_id;
const oter_type_t &ot_type = *ot_type_id;

if( ot_type.has_connections() ) {
// This would be for connected terrain
Expand Down

0 comments on commit 10bac1e

Please sign in to comment.