Ports tgstation/tgstation#40577 - Makes /datum/gas_mixture/share() roughly 5% faster by removing fairly useless abstraction, also contains a small boost to pipelines
This commit is contained in:
@@ -29,6 +29,7 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
|
|||||||
var/last_share = 0
|
var/last_share = 0
|
||||||
var/list/reaction_results
|
var/list/reaction_results
|
||||||
var/list/analyzer_results //used for analyzer feedback - not initialized until its used
|
var/list/analyzer_results //used for analyzer feedback - not initialized until its used
|
||||||
|
var/gc_share = FALSE // Whether to call garbage_collect() on the sharer during shares, used for immutable mixtures
|
||||||
|
|
||||||
/datum/gas_mixture/New(volume)
|
/datum/gas_mixture/New(volume)
|
||||||
gases = new
|
gases = new
|
||||||
@@ -143,9 +144,6 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
|
|||||||
//Performs air sharing calculations between two gas_mixtures assuming only 1 boundary length
|
//Performs air sharing calculations between two gas_mixtures assuming only 1 boundary length
|
||||||
//Returns: amount of gas exchanged (+ if sharer received)
|
//Returns: amount of gas exchanged (+ if sharer received)
|
||||||
|
|
||||||
/datum/gas_mixture/proc/after_share(datum/gas_mixture/sharer)
|
|
||||||
//called on share's sharer to let it know it just got some gases
|
|
||||||
|
|
||||||
/datum/gas_mixture/proc/temperature_share(datum/gas_mixture/sharer, conduction_coefficient)
|
/datum/gas_mixture/proc/temperature_share(datum/gas_mixture/sharer, conduction_coefficient)
|
||||||
//Performs temperature sharing calculations (via conduction) between two gas_mixtures assuming only 1 boundary length
|
//Performs temperature sharing calculations (via conduction) between two gas_mixtures assuming only 1 boundary length
|
||||||
//Returns: new temperature of the sharer
|
//Returns: new temperature of the sharer
|
||||||
@@ -343,7 +341,8 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
|
|||||||
if(length(cached_gases ^ sharer_gases)) //if all gases were present in both mixtures, we know that no gases are 0
|
if(length(cached_gases ^ sharer_gases)) //if all gases were present in both mixtures, we know that no gases are 0
|
||||||
garbage_collect(cached_gases - sharer_gases) //any gases the sharer had, we are guaranteed to have. gases that it didn't have we are not.
|
garbage_collect(cached_gases - sharer_gases) //any gases the sharer had, we are guaranteed to have. gases that it didn't have we are not.
|
||||||
sharer.garbage_collect(sharer_gases - cached_gases) //the reverse is equally true
|
sharer.garbage_collect(sharer_gases - cached_gases) //the reverse is equally true
|
||||||
sharer.after_share(src, atmos_adjacent_turfs)
|
if (initial(sharer.gc_share))
|
||||||
|
sharer.garbage_collect()
|
||||||
if(temperature_delta > MINIMUM_TEMPERATURE_TO_MOVE || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE)
|
if(temperature_delta > MINIMUM_TEMPERATURE_TO_MOVE || abs(moved_moles) > MINIMUM_MOLES_DELTA_TO_MOVE)
|
||||||
var/our_moles
|
var/our_moles
|
||||||
TOTAL_MOLES(cached_gases,our_moles)
|
TOTAL_MOLES(cached_gases,our_moles)
|
||||||
@@ -351,9 +350,6 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache())
|
|||||||
TOTAL_MOLES(sharer_gases,their_moles)
|
TOTAL_MOLES(sharer_gases,their_moles)
|
||||||
return (temperature_archived*(our_moles + moved_moles) - sharer.temperature_archived*(their_moles - moved_moles)) * R_IDEAL_GAS_EQUATION / volume
|
return (temperature_archived*(our_moles + moved_moles) - sharer.temperature_archived*(their_moles - moved_moles)) * R_IDEAL_GAS_EQUATION / volume
|
||||||
|
|
||||||
/datum/gas_mixture/after_share(datum/gas_mixture/sharer, atmos_adjacent_turfs = 4)
|
|
||||||
return
|
|
||||||
|
|
||||||
/datum/gas_mixture/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity)
|
/datum/gas_mixture/temperature_share(datum/gas_mixture/sharer, conduction_coefficient, sharer_temperature, sharer_heat_capacity)
|
||||||
//transfer of thermal energy (via conduction) between self and sharer
|
//transfer of thermal energy (via conduction) between self and sharer
|
||||||
if(sharer)
|
if(sharer)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
/datum/gas_mixture/immutable
|
/datum/gas_mixture/immutable
|
||||||
var/initial_temperature
|
var/initial_temperature
|
||||||
|
gc_share = TRUE
|
||||||
|
|
||||||
/datum/gas_mixture/immutable/New()
|
/datum/gas_mixture/immutable/New()
|
||||||
..()
|
..()
|
||||||
@@ -23,9 +24,6 @@
|
|||||||
. = ..(sharer, 0)
|
. = ..(sharer, 0)
|
||||||
garbage_collect()
|
garbage_collect()
|
||||||
|
|
||||||
/datum/gas_mixture/immutable/after_share()
|
|
||||||
garbage_collect()
|
|
||||||
|
|
||||||
/datum/gas_mixture/immutable/react()
|
/datum/gas_mixture/immutable/react()
|
||||||
return 0 //we're immutable.
|
return 0 //we're immutable.
|
||||||
|
|
||||||
|
|||||||
@@ -221,13 +221,16 @@
|
|||||||
if(!P)
|
if(!P)
|
||||||
continue
|
continue
|
||||||
GL += P.return_air()
|
GL += P.return_air()
|
||||||
for(var/obj/machinery/atmospherics/components/binary/valve/V in P.other_atmosmch)
|
for(var/atmosmch in P.other_atmosmch)
|
||||||
if(V.on)
|
if (istype(atmosmch, /obj/machinery/atmospherics/components/binary/valve))
|
||||||
PL |= V.parents[1]
|
var/obj/machinery/atmospherics/components/binary/valve/V = atmosmch
|
||||||
PL |= V.parents[2]
|
if(V.on)
|
||||||
for(var/obj/machinery/atmospherics/components/unary/portables_connector/C in P.other_atmosmch)
|
PL |= V.parents[1]
|
||||||
if(C.connected_device)
|
PL |= V.parents[2]
|
||||||
GL += C.portableConnectorReturnAir()
|
else if (istype(atmosmch, /obj/machinery/atmospherics/components/unary/portables_connector))
|
||||||
|
var/obj/machinery/atmospherics/components/unary/portables_connector/C = atmosmch
|
||||||
|
if(C.connected_device)
|
||||||
|
GL += C.portableConnectorReturnAir()
|
||||||
|
|
||||||
var/total_thermal_energy = 0
|
var/total_thermal_energy = 0
|
||||||
var/total_heat_capacity = 0
|
var/total_heat_capacity = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user