From 533202ab793fca8096dd69f6b28e4e79f42d217b Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Fri, 4 Sep 2020 11:18:24 +0300 Subject: [PATCH] Use constant references in function parameters --- src/activity_actor.cpp | 2 +- src/avatar_action.cpp | 2 +- src/avatar_action.h | 3 ++- src/effect.cpp | 2 +- src/effect.h | 2 +- src/iuse.cpp | 2 +- src/overmap.cpp | 2 +- src/overmap.h | 2 +- src/vehicle.h | 2 +- src/vehicle_move.cpp | 2 +- tests/char_biometrics_test.cpp | 2 +- tools/format/getpost.h | 2 +- 12 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index e3954f95480a2..c54288e91f4cd 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -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(); diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index a570955152b7a..ddf0f0af521d8 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -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 consume_menu_selections, + const std::vector &consume_menu_selections, const std::vector &consume_menu_selected_items, const std::string &consume_menu_filter ) { diff --git a/src/avatar_action.h b/src/avatar_action.h index 0c69d2aadc5ac..b23cc48e19886 100644 --- a/src/avatar_action.h +++ b/src/avatar_action.h @@ -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 consume_menu_selections, +void eat( avatar &you, const item_location &loc, + const std::vector &consume_menu_selections, const std::vector &consume_menu_selected_items, const std::string &consume_menu_filter ); // special rules for eating: grazing etc diff --git a/src/effect.cpp b/src/effect.cpp index 4ff7d2e81ef1f..0014a9be5db49 100644 --- a/src/effect.cpp +++ b/src/effect.cpp @@ -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; } diff --git a/src/effect.h b/src/effect.h index 1b0cd5daa6646..98b46c27352e4 100644 --- a/src/effect.h +++ b/src/effect.h @@ -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; diff --git a/src/iuse.cpp b/src/iuse.cpp index 5122ee802b49d..76126aae3636d 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -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 fishable_locations = g->get_fishable_locations( 60, pos ); std::vector fishables = g->get_fishable_monsters( fishable_locations ); diff --git a/src/overmap.cpp b/src/overmap.cpp index cd4f150fe8158..9a249ac9d0745 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -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( std::max( 1.0, 1.0 / settings.river_scale ) ); diff --git a/src/overmap.h b/src/overmap.h index 2c6490ee39c7a..66655ea41b0cf 100644 --- a/src/overmap.h +++ b/src/overmap.h @@ -407,7 +407,7 @@ class overmap const std::unordered_map &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, diff --git a/src/vehicle.h b/src/vehicle.h index a471cc2c01d86..bf98d4574b284 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -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 k_traction_cache = cata::nullopt ); + const cata::optional &k_traction_cache = cata::nullopt ); //deceleration due to ground friction and air resistance int slowdown( int velocity ) const; diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 7535b96c9c73e..2e9dad4524562 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -119,7 +119,7 @@ int vehicle::slowdown( int at_velocity ) const } void vehicle:: smart_controller_handle_turn( bool thrusting, - cata::optional k_traction_cache ) + const cata::optional &k_traction_cache ) { if( !engine_on || !has_enabled_smart_controller ) { diff --git a/tests/char_biometrics_test.cpp b/tests/char_biometrics_test.cpp index 27314822780a0..73df8e6f47064 100644 --- a/tests/char_biometrics_test.cpp +++ b/tests/char_biometrics_test.cpp @@ -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, " " ); diff --git a/tools/format/getpost.h b/tools/format/getpost.h index 6f33c71882879..bdb07c176d534 100644 --- a/tools/format/getpost.h +++ b/tools/format/getpost.h @@ -31,7 +31,7 @@ THE SOFTWARE. #include #include -inline std::string urlDecode( std::string str ) +inline std::string urlDecode( const std::string &str ) { std::string temp; int i;