mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 12:41:09 +01:00
[MIRROR] Speeds up the preference menu, significantly. Adds object pooling, other stuff too [MDB IGNORE] (#9962)
* Speeds up the preference menu, significantly. Adds object pooling, other stuff too * First fixes * Feex * Quick fix for the unit test to shut up * Fixing the runtime with randomly-colored jumpsuits * Fixes that one hard del Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com> Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
This commit is contained in:
co-authored by
LemonInTheDark
GoldenAlpharex
GoldenAlpharex
parent
f7a4750b59
commit
b7164873d4
@@ -115,14 +115,33 @@
|
||||
/datum/component/storage/PreTransfer()
|
||||
update_actions()
|
||||
|
||||
/datum/component/storage/proc/set_holdable(can_hold_list, cant_hold_list)
|
||||
can_hold_description = generate_hold_desc(can_hold_list)
|
||||
/// Almost 100% of the time the lists passed into set_holdable are reused for each instance of the component
|
||||
/// Just fucking cache it 4head
|
||||
/// Yes I could generalize this, but I don't want anyone else using it. in fact, DO NOT COPY THIS
|
||||
/// If you find yourself needing this pattern, you're likely better off using static typecaches
|
||||
/// I'm not because I do not trust implementers of the storage component to use them, BUT
|
||||
/// IF I FIND YOU USING THIS PATTERN IN YOUR CODE I WILL BREAK YOU ACROSS MY KNEES
|
||||
/// ~Lemon
|
||||
GLOBAL_LIST_EMPTY(cached_storage_typecaches)
|
||||
|
||||
if (can_hold_list != null)
|
||||
can_hold = string_list(typecacheof(can_hold_list))
|
||||
/datum/component/storage/proc/set_holdable(list/can_hold_list, list/cant_hold_list)
|
||||
if(!islist(can_hold_list))
|
||||
can_hold_list = list(can_hold_list)
|
||||
if(!islist(cant_hold_list))
|
||||
cant_hold_list = list(cant_hold_list)
|
||||
|
||||
can_hold_description = generate_hold_desc(can_hold_list)
|
||||
if (can_hold_list)
|
||||
var/unique_key = can_hold_list.Join("-")
|
||||
if(!GLOB.cached_storage_typecaches[unique_key])
|
||||
GLOB.cached_storage_typecaches[unique_key] = typecacheof(can_hold_list)
|
||||
can_hold = GLOB.cached_storage_typecaches[unique_key]
|
||||
|
||||
if (cant_hold_list != null)
|
||||
cant_hold = string_list(typecacheof(cant_hold_list))
|
||||
var/unique_key = cant_hold_list.Join("-")
|
||||
if(!GLOB.cached_storage_typecaches[unique_key])
|
||||
GLOB.cached_storage_typecaches[unique_key] = typecacheof(cant_hold_list)
|
||||
cant_hold = GLOB.cached_storage_typecaches[unique_key]
|
||||
|
||||
/datum/component/storage/proc/generate_hold_desc(can_hold_list)
|
||||
var/list/desc = list()
|
||||
|
||||
Reference in New Issue
Block a user