From e1a66a9f79cdf6520be177fa3f6ad22252fb992a Mon Sep 17 00:00:00 2001 From: Contrabang <91113370+Contrabang@users.noreply.github.com> Date: Mon, 6 May 2024 15:16:51 -0400 Subject: [PATCH] Adds performance to the strip menu (#25108) * performance * lies * review --- code/datums/elements/strippable.dm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/datums/elements/strippable.dm b/code/datums/elements/strippable.dm index 668f723fe60..25d31342532 100644 --- a/code/datums/elements/strippable.dm +++ b/code/datums/elements/strippable.dm @@ -277,6 +277,9 @@ /// A lazy list of user mobs to a list of strip menu keys that they're interacting with var/list/interactions + /// Associated list of "[icon][icon_state]" = base64 representation of icon. Used for PERFORMANCE. + var/static/list/base64_cache = list() + /datum/strip_menu/New(atom/movable/owner, datum/element/strippable/strippable) . = ..() src.owner = owner @@ -341,7 +344,10 @@ LAZYINITLIST(result) - result["icon"] = icon2base64(icon(item.icon, item.icon_state, dir = SOUTH, frame = 1, moving = FALSE)) + var/key = "[item.icon],[item.icon_state]" + if(!(key in base64_cache)) + base64_cache[key] = icon2base64(icon(item.icon, item.icon_state, dir = SOUTH, frame = 1, moving = FALSE)) + result["icon"] = base64_cache[key] result["name"] = item.name var/real_alts = item_data.get_alternate_actions(owner, user)