Skip to content

Commit

Permalink
Reduces timer insertion cost by 80%
Browse files Browse the repository at this point in the history
Timer name generation involved a LOT of string shit, some in ways where
the string only existed for a moment. This costs a good bit of time, and
can be reduced with only minimal impacts on the end product, so let's do
that
  • Loading branch information
LemonInTheDark committed Jun 17, 2023
1 parent 744da36 commit 4bc80ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion code/controllers/subsystem/timer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,17 @@ SUBSYSTEM_DEF(timer)
* If the timed event is tracking client time, it will be added to a special bucket.
*/
/datum/timedevent/proc/bucketJoin()
// Generate debug-friendly name for timer
// Generate debug-friendly name for timer, more or less complex/expensive depending on defines
#if defined(TIMER_DEBUG)
var/static/list/bitfield_flags = list("TIMER_UNIQUE", "TIMER_OVERRIDE", "TIMER_CLIENT_TIME", "TIMER_STOPPABLE", "TIMER_NO_HASH_WAIT", "TIMER_LOOP")
name = "Timer: [id] ([text_ref(src)]), TTR: [timeToRun], wait:[wait] Flags: [jointext(bitfield_to_list(flags, bitfield_flags), ", ")], \
callBack: [text_ref(callBack)], callBack.object: [callBack.object][text_ref(callBack.object)]([getcallingtype()]), \
callBack.delegate:[callBack.delegate]([callBack.arguments ? callBack.arguments.Join(", ") : ""]), source: [source]"
#else
name = "Timer: [id] ([text_ref(src)]), TTR: [timeToRun], wait:[wait] Flags: [flags], \
callBack: [text_ref(callBack)], callBack.object: [callBack.object]([getcallingtype()]), \
callBack.delegate:[callBack.delegate], source: [source]"
#endif

if (bucket_joined)
stack_trace("Bucket already joined! [name]")
Expand Down

0 comments on commit 4bc80ec

Please sign in to comment.