Skip to content

Commit

Permalink
LibGUI: Reduce amount we init for FileIconProvider::filetype_image_icon
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aJanuary authored and awesomekling committed Aug 20, 2021
1 parent 947b61c commit ac05555
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Userland/Libraries/LibGUI/FileIconProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ac05555

Please sign in to comment.