summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndrew January <ajanuary@evertz.com>2021-08-17 11:31:11 +0100
committerAndreas Kling <kling@serenityos.org>2021-08-20 15:31:22 +0200
commitac055554f6b353c185d24df1a21dc4920abc05bf (patch)
tree190b48666855c7b5d14ba82339f0a783ac320c78 /Userland/Libraries/LibGUI
parent947b61c1de7fa00243d4475157304e2d0a06f455 (diff)
downloadserenity-ac055554f6b353c185d24df1a21dc4920abc05bf.zip
LibGUI: Reduce amount we init for FileIconProvider::filetype_image_icon
Instead of loading every icon, only load the filetype image icon if it hasn't been already. This icon is used by IconViews that need to lazily load thumbnails, which don't need any of the other icon types. Spending the time to load the unneeded images was causing delays to first paint in BackgroundSettings.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/FileIconProvider.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp
index d06c8d0a50..4345ece13b 100644
--- a/Userland/Libraries/LibGUI/FileIconProvider.cpp
+++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp
@@ -48,6 +48,15 @@ static void initialize_executable_icon_if_needed()
s_executable_icon = Icon::default_icon("filetype-executable");
}
+static void initialize_filetype_image_icon_if_needed()
+{
+ static bool initialized = false;
+ if (initialized)
+ return;
+ initialized = true;
+ s_filetype_image_icon = Icon::default_icon("filetype-image");
+}
+
static void initialize_if_needed()
{
static bool s_initialized = false;
@@ -70,8 +79,7 @@ static void initialize_if_needed()
s_symlink_icon = Icon::default_icon("filetype-symlink");
s_socket_icon = Icon::default_icon("filetype-socket");
- s_filetype_image_icon = Icon::default_icon("filetype-image");
-
+ initialize_filetype_image_icon_if_needed();
initialize_executable_icon_if_needed();
for (auto& filetype : config->keys("Icons")) {
@@ -114,7 +122,7 @@ Icon FileIconProvider::home_directory_open_icon()
Icon FileIconProvider::filetype_image_icon()
{
- initialize_if_needed();
+ initialize_filetype_image_icon_if_needed();
return s_filetype_image_icon;
}