From 8fee01e33aa1d4eeddc000316fb7a824c72c7bc2 Mon Sep 17 00:00:00 2001 From: Ghilker <42839747+Ghilker@users.noreply.github.com> Date: Wed, 1 Dec 2021 23:03:20 +0100 Subject: [PATCH] performance improvement for process_cell() (#62730) About The Pull Request Increase performances on /turf/open/process_cell() by changing a typed for and making use of as anything, plus removed unnecessary proc call Why It's Good For The Game The test has been done in a controlled environment, a 7x7 airless room with one canister of plasma and one canister of oxygen released inside. The profiling ran from the start of the fire to the end of it. Before any changes: image After the as anything forloop: image After the archive() removal: image Changelog cl code: increased atmos performances a bit more /cl --- code/__DEFINES/atmospherics/atmos_helpers.dm | 5 +++++ .../atmospherics/environmental/LINDA_turf_tile.dm | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/code/__DEFINES/atmospherics/atmos_helpers.dm b/code/__DEFINES/atmospherics/atmos_helpers.dm index 88702147646..4610499ab9c 100644 --- a/code/__DEFINES/atmospherics/atmos_helpers.dm +++ b/code/__DEFINES/atmospherics/atmos_helpers.dm @@ -70,3 +70,8 @@ GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0)) #define TURFS_CAN_SHARE(T1, T2) (LAZYACCESS(T2.atmos_adjacent_turfs, T1) || LAZYLEN(T1.atmos_adjacent_turfs & T2.atmos_adjacent_turfs)) //Use this to see if a turf is fully blocked or not, think windows or firelocks. Fails with 1x1 non full tile windows, but it's not worth the cost. #define TURF_SHARES(T) (LAZYLEN(T.atmos_adjacent_turfs)) + +#define LINDA_CYCLE_ARCHIVE(turf)\ + turf.air.archive();\ + turf.archived_cycle = SSair.times_fired;\ + turf.temperature_archived = turf.temperature; diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm index 81afa57c179..b09a4bba60b 100644 --- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm +++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm @@ -145,9 +145,7 @@ temperature_archived = temperature /turf/open/archive() - air.archive() - archived_cycle = SSair.times_fired - temperature_archived = temperature + LINDA_CYCLE_ARCHIVE(src) /////////////////////////GAS OVERLAYS////////////////////////////// @@ -242,7 +240,7 @@ /turf/open/process_cell(fire_count) if(archived_cycle < fire_count) //archive self if not already done - archive() + LINDA_CYCLE_ARCHIVE(src) current_cycle = fire_count var/cached_ticker = significant_share_ticker @@ -259,12 +257,10 @@ max_share = 0 //Gotta reset our tracker #endif - for(var/t in adjacent_turfs) - var/turf/open/enemy_tile = t - + for(var/turf/open/enemy_tile as anything in adjacent_turfs) if(fire_count <= enemy_tile.current_cycle) continue - enemy_tile.archive() + LINDA_CYCLE_ARCHIVE(enemy_tile) /******************* GROUP HANDLING START *****************************************************************/ @@ -311,7 +307,7 @@ if (planetary_atmos) //share our air with the "atmosphere" "above" the turf var/datum/gas_mixture/planetary_mix = SSair.planetary[initial_gas_mix] // archive ourself again so we don't accidentally share more gas than we currently have - archive() + LINDA_CYCLE_ARCHIVE(src) if(our_air.compare(planetary_mix)) if(!our_excited_group) var/datum/excited_group/new_group = new