Fixes a long lasting runtime with filter data priority sorting.

This commit is contained in:
Ghommie
2020-01-06 13:11:47 +01:00
parent 9fc65f79f5
commit 3c13113daa
2 changed files with 6 additions and 4 deletions
+4 -1
View File
@@ -35,7 +35,7 @@ GLOBAL_VAR_INIT(cmp_field, "name")
/proc/cmp_datum_text_dsc(datum/a, datum/b, variable)
return sorttext(a.vars[variable], b.vars[variable])
/proc/cmp_ckey_asc(client/a, client/b)
return sorttext(b.ckey, a.ckey)
@@ -51,6 +51,9 @@ GLOBAL_VAR_INIT(cmp_field, "name")
/proc/cmp_subsystem_priority(datum/controller/subsystem/a, datum/controller/subsystem/b)
return a.priority - b.priority
/proc/cmp_filter_data_priority(list/A, list/B)
return A["priority"] - B["priority"]
/proc/cmp_timer(datum/timedevent/a, datum/timedevent/b)
return a.timeToRun - b.timeToRun
+2 -3
View File
@@ -1158,8 +1158,7 @@
target.log_message(reverse_message, LOG_ATTACK, color="orange", log_globally=FALSE)
/atom/movable/proc/add_filter(name,priority,list/params)
if(!filter_data)
filter_data = list()
LAZYINITLIST(filter_data)
var/list/p = params.Copy()
p["priority"] = priority
filter_data[name] = p
@@ -1167,7 +1166,7 @@
/atom/movable/proc/update_filters()
filters = null
sortTim(filter_data,associative = TRUE)
filter_data = sortTim(filter_data, /proc/cmp_filter_data_priority, TRUE)
for(var/f in filter_data)
var/list/data = filter_data[f]
var/list/arguments = data.Copy()