Skip to content

Commit

Permalink
Capture player by reference in comestible inventory lambdas (#26272)
Browse files Browse the repository at this point in the history
The lambdas for determining calories and joy for the player in the
comestible menu were capturing a copy of the player. With the
current map memory bugs, this meant a potentially very large object was
being copied several times, every time the comestible menu was
displayed, leading to a large delay.
  • Loading branch information
ralreegorganon authored and kevingranade committed Oct 16, 2018
1 parent 682888a commit 320fbb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/game_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class comestible_inventory_preset : public inventory_selector_preset
public:
comestible_inventory_preset( const player &p ) : inventory_selector_preset(), p( p ) {

append_cell( [ p, this ]( const item_location & loc ) {
append_cell( [ &p, this ]( const item_location & loc ) {
return good_bad_none( p.nutrition_for( get_comestible_item( loc ) ) *
islot_comestible::kcal_per_nutr );
}, _( "CALORIES" ) );
Expand All @@ -369,7 +369,7 @@ class comestible_inventory_preset : public inventory_selector_preset
return good_bad_none( get_edible_comestible( loc ).quench );
}, _( "QUENCH" ) );

append_cell( [ p, this ]( const item_location & loc ) {
append_cell( [ &p, this ]( const item_location & loc ) {
const item &it = get_comestible_item( loc );
if( it.has_flag( "MUSHY" ) ) {
return highlight_good_bad_none( p.fun_for( get_comestible_item( loc ) ).first );
Expand Down

0 comments on commit 320fbb3

Please sign in to comment.