Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a cache that keeps up to 50 icon pixbufs. This significantly speeds up modules such as
hyprland-taskbar
when there are windows with high-resolution icons (e.g.vscodium
, which only has a 1024x1024 icon on my system) or a lot of icons to be drawn in general.Fix
This PR introduces a simple cache for the icons' pixbufs. The parameters used to call
create_pixbuf
(icon_name
,icon_size
,icons_path
) are put in atuple
and get mapped to the created pixbuf. If the cache size exceeds the set limit (currently 50), the oldest cache entries are removed until the cache size is within limits again.Background
I noticed that opening certain applications would slow down the panel significantly (window and workspace changes took several seconds to become visible on the panel). After a bit of testing, I found out that the creation of some icon pixbufs (function
create_pixbuf
intools.py
) took significantly longer. For instance, while the icon pixbuf creation forfirefox
takes about0.239ms
on average, forvscodium
it's48.042ms
on average (that's over 200 times more!). This results in noticeable lag and unresponsiveness when the panel is redrawn, which happens quite often.