Merge pull request #2617 from CHOMPStationBot/upstream-merge-11179

[MIRROR] Optimize a couple things
This commit is contained in:
Nadyr
2021-07-20 21:45:26 -04:00
committed by GitHub
262 changed files with 547 additions and 976 deletions

View File

@@ -300,7 +300,7 @@ var/list/gamemode_cache = list()
var/static/list/jukebox_track_files
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
var/list/L = subtypesof(/datum/game_mode)
for (var/T in L)
// I wish I didn't have to instance the game modes in order to look up
// their information, but it is the only way (at least that I know of).

View File

@@ -251,8 +251,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
var/list/tickersubsystems = list()
var/list/runlevel_sorted_subsystems = list(list()) //ensure we always have at least one runlevel
var/timer = world.time
for (var/thing in subsystems)
var/datum/controller/subsystem/SS = thing
for (var/datum/controller/subsystem/SS as anything in subsystems)
if (SS.flags & SS_NO_FIRE)
continue
SS.queued_time = 0
@@ -339,8 +338,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
cached_runlevel = checking_runlevel
current_runlevel_subsystems = runlevel_sorted_subsystems[cached_runlevel]
var/stagger = world.time
for(var/I in current_runlevel_subsystems)
var/datum/controller/subsystem/SS = I
for(var/datum/controller/subsystem/SS as anything in current_runlevel_subsystems)
if(SS.next_fire <= world.time)
stagger += world.tick_lag * rand(1, 5)
SS.next_fire = stagger
@@ -553,8 +551,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
for(var/I in runlevel_SS)
subsystemstocheck |= I
for (var/thing in subsystemstocheck)
var/datum/controller/subsystem/SS = thing
for (var/datum/controller/subsystem/SS as anything in subsystemstocheck)
if (!SS || !istype(SS))
//list(SS) is so if a list makes it in the subsystem list, we remove the list, not the contents
subsystems -= list(SS)
@@ -601,8 +598,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
//disallow more than one map to load at once, multithreading it will just cause race conditions
while(map_loading)
stoplag()
for(var/S in subsystems)
var/datum/controller/subsystem/SS = S
for(var/datum/controller/subsystem/SS as anything in subsystems)
SS.StartLoadingMap()
map_loading = TRUE
@@ -611,6 +607,5 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
if(!quiet)
admin_notice("<span class='danger'>Map is finished. Unlocking.</span>", R_DEBUG)
map_loading = FALSE
for(var/S in subsystems)
var/datum/controller/subsystem/SS = S
for(var/datum/controller/subsystem/SS as anything in subsystems)
SS.StopLoadingMap()

View File

@@ -6,8 +6,7 @@ SUBSYSTEM_DEF(assets)
var/list/preload = list()
/datum/controller/subsystem/assets/Initialize(timeofday)
for(var/type in typesof(/datum/asset))
var/datum/asset/A = type
for(var/datum/asset/A as anything in typesof(/datum/asset))
if (type != initial(A._abstract))
get_asset_datum(type)

View File

@@ -38,11 +38,10 @@ SUBSYSTEM_DEF(atoms)
if(atoms)
created_atoms = list()
count = atoms.len
for(var/I in atoms)
var/atom/A = I
for(var/atom/A as anything in atoms)
if(!A.initialized)
if(InitAtom(I, mapload_arg))
atoms -= I
if(InitAtom(A, mapload_arg))
atoms -= A
CHECK_TICK
else
count = 0
@@ -57,8 +56,7 @@ SUBSYSTEM_DEF(atoms)
initialized = INITIALIZATION_INNEW_REGULAR
if(late_loaders.len)
for(var/I in late_loaders)
var/atom/A = I
for(var/atom/A as anything in late_loaders)
A.LateInitialize()
CHECK_TICK
testing("Late initialized [late_loaders.len] atoms")

View File

@@ -13,8 +13,7 @@ SUBSYSTEM_DEF(chat)
/datum/controller/subsystem/chat/fire()
var/list/msg_queue = src.msg_queue // Local variable for sanic speed.
for(var/i in msg_queue)
var/client/C = i
for(var/client/C as anything in msg_queue)
var/list/messages = msg_queue[C]
msg_queue -= C
if (C)

View File

@@ -23,11 +23,10 @@ SUBSYSTEM_DEF(circuit)
/datum/controller/subsystem/circuit/proc/circuits_init()
//Cached lists for free performance
for(var/path in typesof(/obj/item/integrated_circuit))
var/obj/item/integrated_circuit/IC = path
var/name = initial(IC.name)
all_components[name] = path // Populating the component lists
cached_components[IC] = new path
for(var/obj/item/integrated_circuit/IC as anything in typesof(/obj/item/integrated_circuit))
var/path = IC
all_components[initial(IC.name)] = path // Populating the component lists
cached_components[path] = new path
if(!(initial(IC.spawn_flags) & (IC_SPAWN_DEFAULT | IC_SPAWN_RESEARCH)))
continue
@@ -38,11 +37,10 @@ SUBSYSTEM_DEF(circuit)
var/list/category_list = circuit_fabricator_recipe_list[category]
category_list += IC // Populating the fabricator categories
for(var/path in typesof(/obj/item/device/electronic_assembly))
var/obj/item/device/electronic_assembly/A = path
var/name = initial(A.name)
all_assemblies[name] = path
cached_assemblies[A] = new path
for(var/obj/item/device/electronic_assembly/A as anything in typesof(/obj/item/device/electronic_assembly))
var/path = A
all_assemblies[initial(A.name)] = path
cached_assemblies[path] = new path
circuit_fabricator_recipe_list["Assemblies"] = list(

View File

@@ -13,7 +13,7 @@ SUBSYSTEM_DEF(events)
var/datum/event_meta/new_event = new
/datum/controller/subsystem/events/Initialize()
allEvents = typesof(/datum/event) - /datum/event
allEvents = subtypesof(/datum/event)
event_containers = list(
EVENT_LEVEL_MUNDANE = new/datum/event_container/mundane,
EVENT_LEVEL_MODERATE = new/datum/event_container/moderate,

View File

@@ -14,8 +14,7 @@ SUBSYSTEM_DEF(event_ticker)
// Process active events.
/datum/controller/subsystem/event_ticker/fire(resumed)
for(var/E in active_events)
var/datum/event2/event/event = E
for(var/datum/event2/event/event as anything in active_events)
event.process()
if(event.finished)
event_finished(event)

View File

@@ -74,8 +74,7 @@ SUBSYSTEM_DEF(game_master)
chosen_event.enabled = FALSE
if(chosen_event.event_class)
// Disable similar events, too.
for(var/M in available_events)
var/datum/event2/meta/meta = M
for(var/datum/event2/meta/meta as anything in available_events)
if(meta.event_class == chosen_event.event_class)
meta.enabled = FALSE
@@ -235,8 +234,7 @@ SUBSYSTEM_DEF(game_master)
dat += "<th colspan='2'>Players</td>"
dat += "</tr>"
for(var/P in player_list)
var/mob/M = P
for(var/mob/M as anything in player_list)
dat += "<tr>"
dat += "<td>[M] ([M.ckey])</td>"
dat += "<td>[metric.assess_player_activity(M)]%</td>"
@@ -255,8 +253,7 @@ SUBSYSTEM_DEF(game_master)
dat += "<th>Buttons</th>"
dat += "</tr>"
for(var/E in available_events)
var/datum/event2/meta/event = E
for(var/datum/event2/meta/event as anything in available_events)
dat += "<tr>"
if(!event.enabled)
dat += "<td><strike>[event.name]</strike></td>"
@@ -285,8 +282,7 @@ SUBSYSTEM_DEF(game_master)
dat += "<th>Buttons</th>"
dat += "</tr>"
for(var/E in SSevent_ticker.active_events)
var/datum/event2/event/event = E
for(var/datum/event2/event/event as anything in SSevent_ticker.active_events)
dat += "<tr>"
dat += "<td>[event.type]</td>"
dat += "<td>[event.time_started]</td>"
@@ -309,8 +305,7 @@ SUBSYSTEM_DEF(game_master)
dat += "<th>Finish Time</th>"
dat += "</tr>"
for(var/E in SSevent_ticker.finished_events)
var/datum/event2/event/event = E
for(var/datum/event2/event/event as anything in SSevent_ticker.finished_events)
dat += "<tr>"
dat += "<td>[event.type]</td>"
dat += "<td>[event.time_started]</td>"

View File

@@ -172,8 +172,7 @@ SUBSYSTEM_DEF(garbage)
log_world("## TESTING: GC: -- \ref[D] | [type] was unable to be GC'd --")
#ifdef TESTING
for(var/c in GLOB.admins) //Using testing() here would fill the logs with ADMIN_VV garbage
var/client/admin = c
for(var/client/admin as anything in GLOB.admins) //Using testing() here would fill the logs with ADMIN_VV garbage
if(!check_rights_for(admin, R_ADMIN))
continue
to_chat(admin, "## TESTING: GC: -- [ADMIN_VV(D)] | [type] was unable to be GC'd --")

View File

@@ -34,11 +34,10 @@ SUBSYSTEM_DEF(mapping)
..()
/datum/controller/subsystem/mapping/proc/load_map_templates()
for(var/T in subtypesof(/datum/map_template))
var/datum/map_template/template = T
for(var/datum/map_template/template as anything in subtypesof(/datum/map_template))
if(!(initial(template.mappath))) // If it's missing the actual path its probably a base type or being used for inheritence.
continue
template = new T()
template = new template()
map_templates[template.name] = template
return TRUE
@@ -113,8 +112,7 @@ SUBSYSTEM_DEF(mapping)
MT.load_new_z(centered = FALSE)
/datum/controller/subsystem/mapping/proc/preloadShelterTemplates()
for(var/item in subtypesof(/datum/map_template/shelter))
var/datum/map_template/shelter/shelter_type = item
for(var/datum/map_template/shelter/shelter_type as anything in subtypesof(/datum/map_template/shelter))
if(!(initial(shelter_type.mappath)))
continue
var/datum/map_template/shelter/S = new shelter_type()

View File

@@ -12,11 +12,10 @@ SUBSYSTEM_DEF(persistence)
/datum/controller/subsystem/persistence/Initialize()
. = ..()
for(var/thing in subtypesof(/datum/persistent))
var/datum/persistent/P = thing
for(var/datum/persistent/P as anything in subtypesof(/datum/persistent))
if(initial(P.name))
P = new P
persistence_datums[thing] = P
persistence_datums[P.type] = P
P.Initialize()
/datum/controller/subsystem/persistence/Shutdown()

View File

@@ -111,8 +111,7 @@ SUBSYSTEM_DEF(planets)
/datum/controller/subsystem/planets/proc/updateTemp(var/datum/planet/P)
//Set new temperatures
for(var/W in P.planet_walls)
var/turf/unsimulated/wall/planetary/wall = W
for(var/turf/unsimulated/wall/planetary/wall as anything in P.planet_walls)
wall.set_temperature(P.weather_holder.temperature)
CHECK_TICK
@@ -120,8 +119,7 @@ SUBSYSTEM_DEF(planets)
var/count = 100000
while(count > 0)
count--
for(var/planet in planets)
var/datum/planet/P = planet
for(var/datum/planet/P as anything in planets)
if(P.weather_holder)
P.weather_holder.change_weather(pick(P.weather_holder.allowed_weather_types))
sleep(3)

View File

@@ -62,7 +62,7 @@ SUBSYSTEM_DEF(plants)
accessible_product_sprites |= base
// Populate the global seed datum list.
for(var/type in typesof(/datum/seed)-/datum/seed)
for(var/type in subtypesof(/datum/seed))
var/datum/seed/S = new type
seeds[S.name] = S
S.uid = "[seeds.len]"

View File

@@ -33,11 +33,10 @@ PROCESSING_SUBSYSTEM_DEF(instruments)
songs -= S
/datum/controller/subsystem/processing/instruments/proc/initialize_instrument_data()
for(var/path in subtypesof(/datum/instrument))
var/datum/instrument/I = path
if(initial(I.abstract_type) == path)
for(var/datum/instrument/I as anything in subtypesof(/datum/instrument))
if(initial(I.abstract_type) == I)
continue
I = new path
I = new I
I.Initialize()
if(!I.id)
qdel(I)

View File

@@ -19,7 +19,6 @@ PROCESSING_SUBSYSTEM_DEF(projectiles)
/datum/controller/subsystem/processing/projectiles/proc/set_pixel_speed(new_speed)
global_pixel_speed = new_speed
for(var/i in processing)
var/obj/item/projectile/P = i
for(var/obj/item/projectile/P as anything in processing)
if(istype(P)) //there's non projectiles on this too.
P.set_pixel_speed(new_speed)

View File

@@ -63,8 +63,7 @@ SUBSYSTEM_DEF(radiation)
if(!istype(T))
return
for(var/value in sources)
var/datum/radiation_source/source = value
for(var/datum/radiation_source/source as anything in sources)
if(source.rad_power < .)
continue // Already being affected by a stronger source

View File

@@ -119,8 +119,7 @@ SUBSYSTEM_DEF(shuttles)
landmarks_still_needed[landmark_tag] = given_sector // Landmark isn't registered yet, queue it to be added once it is.
var/landmarks_to_check = landmarks_awaiting_sector.Copy()
for(var/thing in landmarks_to_check)
var/obj/effect/shuttle_landmark/automatic/landmark = thing
for(var/obj/effect/shuttle_landmark/automatic/landmark as anything in landmarks_to_check)
if(landmark.z in given_sector.map_z)
given_sector.add_landmark(landmark, landmark.shuttle_restricted)
landmarks_awaiting_sector -= landmark
@@ -170,8 +169,7 @@ SUBSYSTEM_DEF(shuttles)
if(overmap_halted == new_setting)
return
overmap_halted = !overmap_halted
for(var/ship in ships)
var/obj/effect/overmap/visitable/ship/ship_effect = ship
for(var/obj/effect/overmap/visitable/ship/ship_effect as anything in ships)
overmap_halted ? ship_effect.halt() : ship_effect.unhalt()
/datum/controller/subsystem/shuttles/stat_entry()

View File

@@ -202,8 +202,7 @@ SUBSYSTEM_DEF(timer)
bucket_count -= length(spent)
for (var/i in spent)
var/datum/timedevent/qtimer = i
for(var/datum/timedevent/qtimer as anything in spent)
if(QDELETED(qtimer))
bucket_count++
continue

View File

@@ -35,8 +35,7 @@ SUBSYSTEM_DEF(vote)
// Before doing the vote, see if anyone is playing.
// If not, just do the transfer.
var/players_are_in_round = FALSE
for(var/a in player_list) // Mobs with clients attached.
var/mob/living/L = a
for(var/mob/living/L as anything in player_list) // Mobs with clients attached.
if(!istype(L)) // Exclude ghosts and other weird things.
continue
if(L.stat == DEAD) // Dead mobs aren't playing.

View File

@@ -41,8 +41,7 @@ SUBSYSTEM_DEF(xenoarch)
continue
var/farEnough = 1
for(var/A in digsite_spawning_turfs)
var/turf/T = A
for(var/turf/T as anything in digsite_spawning_turfs)
if(T in range(5, M))
farEnough = 0
break

View File

@@ -75,8 +75,7 @@
options["MC"] = Master
options["Failsafe"] = Failsafe
options["Configuration"] = config
for(var/i in Master.subsystems)
var/datum/controller/subsystem/S = i
for(var/datum/controller/subsystem/S as anything in Master.subsystems)
if(!istype(S)) //Eh, we're a debug verb, let's have typechecking.
continue
var/strtype = "SS[get_end_section_of_type(S.type)]"