From d39956ca3ea897c012ea70e76ee186ad12d50e4e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 15 Sep 2021 04:33:38 +0200 Subject: [PATCH] [MIRROR] makes the SEND_SIGNAL() define use the ?[] operator, my biggest microop ever? (#8185) * makes the SEND_SIGNAL() define use the ?[] operator to save 11 ns (#61319) if(list?[index]) is very slightly faster than if(list && list[index]) and SEND_SIGNAL() while very cheap is fucking everywhere, so i benchmarked ?[] looking at the last two (Pictures of entries not shown here), 2835487/second -> one iteration every 352.67 nanoseconds for the if(list && list[index]) and 2931099/second -> one iteration every 341.17 nanoseconds, so we saved a grand total of 11 nanoseconds for each SEND_SIGNAL() define! thats the time light in a vacuum takes to travel 3.3 meters! thats a lower one though, the third null list check saved 24 ns and theres probably a fair bit of overhead with the way im benchmarking this since each loop has to check world.timeofday but eh whatever * makes the SEND_SIGNAL() define use the ?[] operator, my biggest microop ever? Co-authored-by: Kylerace --- code/__DEFINES/dcs/helpers.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/__DEFINES/dcs/helpers.dm b/code/__DEFINES/dcs/helpers.dm index 2f6b7590f63..56ea5370c4a 100644 --- a/code/__DEFINES/dcs/helpers.dm +++ b/code/__DEFINES/dcs/helpers.dm @@ -2,7 +2,7 @@ /// The datum hosting the signal is automaticaly added as the first argument /// Returns a bitfield gathered from all registered procs /// Arguments given here are packaged in a list and given to _SendSignal -#define SEND_SIGNAL(target, sigtype, arguments...) ( !target.comp_lookup || !target.comp_lookup[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) ) +#define SEND_SIGNAL(target, sigtype, arguments...) ( !target.comp_lookup?[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) ) #define SEND_GLOBAL_SIGNAL(sigtype, arguments...) ( SEND_SIGNAL(SSdcs, sigtype, ##arguments) )