Skip to content

Commit

Permalink
Use constant references in function parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhilkinSerg committed Sep 4, 2020
1 parent 70d9eed commit 533202a
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ static hack_result hack_attempt( Character &who, const bool using_bionic )
}
}

static hack_type get_hack_type( tripoint examp )
static hack_type get_hack_type( const tripoint &examp )
{
hack_type type = hack_type::NONE;
map &here = get_map();
Expand Down
2 changes: 1 addition & 1 deletion src/avatar_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void avatar_action::eat( avatar &you, const item_location &loc )
}

void avatar_action::eat( avatar &you, const item_location &loc,
std::vector<int> consume_menu_selections,
const std::vector<int> &consume_menu_selections,
const std::vector<item_location> &consume_menu_selected_items,
const std::string &consume_menu_filter )
{
Expand Down
3 changes: 2 additions & 1 deletion src/avatar_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace avatar_action
/** Eat food or fuel 'E' (or 'a') */
void eat( avatar &you );
void eat( avatar &you, const item_location &loc );
void eat( avatar &you, const item_location &loc, std::vector<int> consume_menu_selections,
void eat( avatar &you, const item_location &loc,
const std::vector<int> &consume_menu_selections,
const std::vector<item_location> &consume_menu_selected_items,
const std::string &consume_menu_filter );
// special rules for eating: grazing etc
Expand Down
2 changes: 1 addition & 1 deletion src/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ bodypart_id effect::get_bp() const
{
return bp.id();
}
void effect::set_bp( bodypart_str_id part )
void effect::set_bp( const bodypart_str_id &part )
{
bp = part;
}
Expand Down
2 changes: 1 addition & 1 deletion src/effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class effect
/** Returns the targeted body_part of the effect. This is num_bp for untargeted effects. */
bodypart_id get_bp() const;
/** Sets the targeted body_part of an effect. */
void set_bp( bodypart_str_id part );
void set_bp( const bodypart_str_id &part );

/** Returns true if an effect is permanent, i.e. it's duration does not decrease over time. */
bool is_permanent() const;
Expand Down
2 changes: 1 addition & 1 deletion src/iuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ int iuse::remove_all_mods( player *p, item *, bool, const tripoint & )
return 0;
}

static bool good_fishing_spot( tripoint pos, player *p )
static bool good_fishing_spot( const tripoint &pos, player *p )
{
std::unordered_set<tripoint> fishable_locations = g->get_fishable_locations( 60, pos );
std::vector<monster *> fishables = g->get_fishable_monsters( fishable_locations );
Expand Down
2 changes: 1 addition & 1 deletion src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,7 @@ void overmap::place_roads( const overmap *north, const overmap *east, const over
connect_closest_points( road_points, 0, *local_road );
}

void overmap::place_river( point_om_omt pa, point_om_omt pb )
void overmap::place_river( const point_om_omt &pa, const point_om_omt &pb )
{
const oter_id river_center( "river_center" );
int river_chance = static_cast<int>( std::max( 1.0, 1.0 / settings.river_scale ) );
Expand Down
2 changes: 1 addition & 1 deletion src/overmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ class overmap
const std::unordered_map<tripoint_om_omt, std::string> &needs_conversion );

// Overall terrain
void place_river( point_om_omt pa, point_om_omt pb );
void place_river( const point_om_omt &pa, const point_om_omt &pb );
void place_forests();
void place_lakes();
void place_rivers( const overmap *north, const overmap *east, const overmap *south,
Expand Down
2 changes: 1 addition & 1 deletion src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ class vehicle
* @param k_traction_cache cached value of vehicle::k_traction, if empty, will be computed
*/
void smart_controller_handle_turn( bool thrusting = false,
cata::optional<float> k_traction_cache = cata::nullopt );
const cata::optional<float> &k_traction_cache = cata::nullopt );

//deceleration due to ground friction and air resistance
int slowdown( int velocity ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int vehicle::slowdown( int at_velocity ) const
}

void vehicle:: smart_controller_handle_turn( bool thrusting,
cata::optional<float> k_traction_cache )
const cata::optional<float> &k_traction_cache )
{

if( !engine_on || !has_enabled_smart_controller ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/char_biometrics_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ TEST_CASE( "activity level reset, increase and decrease", "[biometrics][activity
}

// Return a string with multiple consecutive spaces replaced with a single space
static std::string condensed_spaces( const std::string text )
static std::string condensed_spaces( const std::string &text )
{
std::regex spaces( " +" );
return std::regex_replace( text, spaces, " " );
Expand Down
2 changes: 1 addition & 1 deletion tools/format/getpost.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ THE SOFTWARE.
#include <map>
#include <new>

inline std::string urlDecode( std::string str )
inline std::string urlDecode( const std::string &str )
{
std::string temp;
int i;
Expand Down

0 comments on commit 533202a

Please sign in to comment.