From 5746586d789451be189dd5a9d3265d5698fe087e Mon Sep 17 00:00:00 2001 From: Sinestia <40812746+Sinestia@users.noreply.github.com> Date: Wed, 7 Jul 2021 19:21:42 -0500 Subject: [PATCH 1/2] Cache asset/mappings results (#59914) (#4760) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/modules/asset_cache/asset_list.dm | 8 ++++++++ code/modules/tgui/tgui_window.dm | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/modules/asset_cache/asset_list.dm b/code/modules/asset_cache/asset_list.dm index 221febbe14d..3f9e8c3fcca 100644 --- a/code/modules/asset_cache/asset_list.dm +++ b/code/modules/asset_cache/asset_list.dm @@ -11,6 +11,7 @@ GLOBAL_LIST_EMPTY(asset_datums) /datum/asset var/_abstract = /datum/asset + var/cached_url_mappings /datum/asset/New() GLOB.asset_datums[type] = src @@ -19,6 +20,13 @@ GLOBAL_LIST_EMPTY(asset_datums) /datum/asset/proc/get_url_mappings() return list() +/// Returns a cached tgui message of URL mappings +/datum/asset/proc/get_serialized_url_mappings() + if (isnull(cached_url_mappings)) + cached_url_mappings = TGUI_CREATE_MESSAGE("asset/mappings", get_url_mappings()) + + return cached_url_mappings + /datum/asset/proc/register() return diff --git a/code/modules/tgui/tgui_window.dm b/code/modules/tgui/tgui_window.dm index b4a509c6da9..08f0ad704b6 100644 --- a/code/modules/tgui/tgui_window.dm +++ b/code/modules/tgui/tgui_window.dm @@ -251,7 +251,7 @@ if(istype(asset, /datum/asset/spritesheet)) var/datum/asset/spritesheet/spritesheet = asset send_message("asset/stylesheet", spritesheet.css_filename()) - send_message("asset/mappings", asset.get_url_mappings()) + send_raw_message(asset.get_serialized_url_mappings()) /** * private From 6d6d782e884f0e174274f94fb469c5ebf9d837dc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 8 Jul 2021 00:22:13 +0000 Subject: [PATCH 2/2] Ports Cache asset/mappings results