mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
[MIRROR] I shaved 2 seconds off atom init times and it's boring [MDB IGNORE] (#16176)
* I shaved 2 seconds off atom init times and it's boring (#69742) * I shaved 2 seconds off init times by moving some sleep tests to only run during unit testing and using ``as anything`` * I shaved 2 seconds off atom init times and it's boring Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
@@ -85,12 +85,18 @@ SUBSYSTEM_DEF(atoms)
|
||||
if (atoms_to_return)
|
||||
LAZYINITLIST(created_atoms)
|
||||
|
||||
#ifdef TESTING
|
||||
var/count
|
||||
#endif
|
||||
|
||||
var/list/mapload_arg = list(TRUE)
|
||||
|
||||
if(atoms)
|
||||
#ifdef TESTING
|
||||
count = atoms.len
|
||||
for(var/I in 1 to count)
|
||||
#endif
|
||||
|
||||
for(var/I in 1 to atoms.len)
|
||||
var/atom/A = atoms[I]
|
||||
if(!(A.flags_1 & INITIALIZED_1))
|
||||
CHECK_TICK
|
||||
@@ -98,17 +104,21 @@ SUBSYSTEM_DEF(atoms)
|
||||
InitAtom(A, TRUE, mapload_arg)
|
||||
PROFILE_INIT_ATOM_END(A)
|
||||
else
|
||||
#ifdef TESTING
|
||||
count = 0
|
||||
for(var/atom/A in world)
|
||||
#endif
|
||||
|
||||
for(var/atom/A as anything in world)
|
||||
if(!(A.flags_1 & INITIALIZED_1))
|
||||
PROFILE_INIT_ATOM_BEGIN()
|
||||
InitAtom(A, FALSE, mapload_arg)
|
||||
PROFILE_INIT_ATOM_END(A)
|
||||
#ifdef TESTING
|
||||
++count
|
||||
#endif
|
||||
CHECK_TICK
|
||||
|
||||
testing("Initialized [count] atoms")
|
||||
pass(count)
|
||||
|
||||
/// Init this specific atom
|
||||
/datum/controller/subsystem/atoms/proc/InitAtom(atom/A, from_template = FALSE, list/arguments)
|
||||
@@ -117,27 +127,33 @@ SUBSYSTEM_DEF(atoms)
|
||||
BadInitializeCalls[the_type] |= BAD_INIT_QDEL_BEFORE
|
||||
return TRUE
|
||||
|
||||
// This is handled and battle tested by dreamchecker. Limit to UNIT_TESTS just in case that ever fails.
|
||||
#ifdef UNIT_TESTS
|
||||
var/start_tick = world.time
|
||||
#endif
|
||||
|
||||
var/result = A.Initialize(arglist(arguments))
|
||||
|
||||
#ifdef UNIT_TESTS
|
||||
if(start_tick != world.time)
|
||||
BadInitializeCalls[the_type] |= BAD_INIT_SLEPT
|
||||
#endif
|
||||
|
||||
var/qdeleted = FALSE
|
||||
|
||||
if(result != INITIALIZE_HINT_NORMAL)
|
||||
switch(result)
|
||||
if(INITIALIZE_HINT_LATELOAD)
|
||||
if(arguments[1]) //mapload
|
||||
late_loaders += A
|
||||
else
|
||||
A.LateInitialize()
|
||||
if(INITIALIZE_HINT_QDEL)
|
||||
qdel(A)
|
||||
qdeleted = TRUE
|
||||
switch(result)
|
||||
if (INITIALIZE_HINT_NORMAL)
|
||||
// pass
|
||||
if(INITIALIZE_HINT_LATELOAD)
|
||||
if(arguments[1]) //mapload
|
||||
late_loaders += A
|
||||
else
|
||||
BadInitializeCalls[the_type] |= BAD_INIT_NO_HINT
|
||||
A.LateInitialize()
|
||||
if(INITIALIZE_HINT_QDEL)
|
||||
qdel(A)
|
||||
qdeleted = TRUE
|
||||
else
|
||||
BadInitializeCalls[the_type] |= BAD_INIT_NO_HINT
|
||||
|
||||
if(!A) //possible harddel
|
||||
qdeleted = TRUE
|
||||
|
||||
Reference in New Issue
Block a user