From 3c03d58c1e19840927128a8fa726f18a9f561e78 Mon Sep 17 00:00:00 2001 From: anothersimulacrum Date: Thu, 12 Aug 2021 14:06:39 -0700 Subject: [PATCH] Optimize get_heat_radiation Cache a variable, use the already fetched maptile to check the terrain at the tile instead of looking up the submap again. --- src/game.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 3c4e7eac1e9b0..237ecaac1e3d1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1273,16 +1273,18 @@ int get_heat_radiation( const tripoint &location, bool direct ) int best_fire = 0; Character &player_character = get_player_character(); map &here = get_map(); + // Convert it to an int id once, instead of 139 times per turn + const field_type_id fd_fire_int = fd_fire.id(); for( const tripoint &dest : here.points_in_radius( location, 6 ) ) { int heat_intensity = 0; maptile mt = here.maptile_at( dest ); - int ffire = maptile_field_intensity( mt, fd_fire ); + int ffire = maptile_field_intensity( mt, fd_fire_int ); if( ffire > 0 ) { heat_intensity = ffire; } else { - heat_intensity = here.ter( dest )->heat_radiation; + heat_intensity = mt.get_ter()->heat_radiation; } if( heat_intensity == 0 ) { // No heat source here