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

@@ -320,8 +320,7 @@
var/proctype = C.signal_procs[src][sigtype]
return NONE | CallAsync(C, proctype, arguments)
. = NONE
for(var/I in target)
var/datum/C = I
for(var/datum/C as anything in target)
if(!C.signal_enabled)
continue
var/proctype = C.signal_procs[src][sigtype]
@@ -444,8 +443,7 @@
var/list/arguments = raw_args.Copy()
arguments[1] = new_comp
var/make_new_component = TRUE
for(var/i in GetComponents(new_type))
var/datum/component/C = i
for(var/datum/component/C as anything in GetComponents(new_type))
if(C.CheckDupeComponent(arglist(arguments)))
make_new_component = FALSE
QDEL_NULL(new_comp)

View File

@@ -402,8 +402,7 @@
var/list/surroundings = get_surroundings(user)
var/list/craftability = list()
for(var/rec in GLOB.crafting_recipes)
var/datum/crafting_recipe/R = rec
for(var/datum/crafting_recipe/R as anything in GLOB.crafting_recipes)
if(!R.always_available && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.
continue
@@ -420,11 +419,10 @@
var/list/data = list()
var/list/crafting_recipes = list()
for(var/rec in GLOB.crafting_recipes)
var/datum/crafting_recipe/R = rec
for(var/datum/crafting_recipe/R as anything in GLOB.crafting_recipes)
if(R.name == "") //This is one of the invalid parents that sneaks in
GLOB.crafting_recipes -= rec
GLOB.crafting_recipes -= R
continue
if(!R.always_available && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.

View File

@@ -99,9 +99,8 @@
/datum/component/material_container/proc/on_examine(datum/source, mob/user, list/examine_texts)
SIGNAL_HANDLER
for(var/I in materials)
var/datum/material/M = I
var/amt = materials[I]
for(var/datum/material/M as anything in materials)
var/amt = materials[M]
if(amt)
examine_texts += "<span class='notice'>It has [amt] units of [lowertext(M.name)] stored.</span>"
@@ -327,13 +326,13 @@
var/list/mats_to_remove = list() //Assoc list MAT | AMOUNT
for(var/x in mats) //Loop through all required materials
var/datum/material/req_mat = x
for(var/datum/material/req_mat as anything in mats) //Loop through all required materials
var/imat = req_mat
if(!istype(req_mat))
req_mat = GET_MATERIAL_REF(req_mat) //Get the ref if necesary
if(!materials[req_mat]) //Do we have the resource?
return FALSE //Can't afford it
var/amount_required = mats[x] * multiplier
var/amount_required = mats[imat] * multiplier
if(!(materials[req_mat] >= amount_required)) // do we have enough of the resource?
return FALSE //Can't afford it
mats_to_remove[req_mat] += amount_required //Add it to the assoc list of things to remove
@@ -392,8 +391,8 @@
if(!mats || !mats.len)
return FALSE
for(var/x in mats) //Loop through all required materials
var/datum/material/req_mat = x
for(var/datum/material/req_mat as anything in mats) //Loop through all required materials
var/imat = req_mat
if(!istype(req_mat))
if(ispath(req_mat) || istext(req_mat)) //Is this an actual material, or is it a category?
req_mat = GET_MATERIAL_REF(req_mat) //Get the ref
@@ -404,7 +403,7 @@
// else
// continue
if(!has_enough_of_material(req_mat, mats[x], multiplier))//Not a category, so just check the normal way
if(!has_enough_of_material(req_mat, mats[imat], multiplier))//Not a category, so just check the normal way
return FALSE
return TRUE

View File

@@ -171,8 +171,7 @@
///Clears the affected_turfs lazylist, removing from its contents the effects of being near the light.
/datum/component/overlay_lighting/proc/clean_old_turfs()
for(var/t in affected_turfs)
var/turf/lit_turf = t
for(var/turf/lit_turf as anything in affected_turfs)
lit_turf.dynamic_lumcount -= lum_power
affected_turfs = null
@@ -434,8 +433,7 @@
. = lum_power
lum_power = new_lum_power
var/difference = . - lum_power
for(var/t in affected_turfs)
var/turf/lit_turf = t
for(var/turf/lit_turf as anything in affected_turfs)
lit_turf.dynamic_lumcount -= difference
///Moves the light directional_atom that emits our "light" based on our position and our direction