mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 16:10:20 +00:00
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.
This commit is contained in:
parent
947b61c1de
commit
ac055554f6
Notes:
sideshowbarker
2024-07-18 05:27:42 +09:00
Author: https://github.com/aJanuary Commit: https://github.com/SerenityOS/serenity/commit/ac055554f6b Pull-request: https://github.com/SerenityOS/serenity/pull/9470 Reviewed-by: https://github.com/awesomekling
1 changed files with 11 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue