SvgItem, FrameSvgItem: look up colors once per image set
Similar to !119 (closed), but a cleaner approach. Non-slop, but assisted by Claude Opus 5.5.
About the bug
SvgItem and FrameSvgItem check for a colors file every time their Kirigami colors or frame contrast change. Even though ImageSet caches lookups, it only does so when they are successful. The fun part is that the default style has no such file.
As a result, startplasma ends up doing a crazy amount of fs calls during startup, exactly 57,643 on my setup. This is inefficient by default, but hurts especially a lot on systems where these operations are costlier (e.g. through proot under Android, and maybe on some file systems too).
A proposal of !119 (closed) (and also my exact initial finding) was to cache path lookups done by these classes, but @mart had some concerns with this approach, so...
Solution
Only look the file up when the item is completed and when its image set changes. Keep the answer in a private flag.
Small enough change that looking at the diff explains it.
Importantly, brings no behavior change... other than one tiny colors file added by hand while Plasma runs is now noticed at the next style change instead of the next color change. But KSvg only loads it while loading a style, so it never really mattered.
Results
| 6.31.0 | 6.31.0 + !119 (closed) | 6.31.0 + ts | |
|---|---|---|---|
plasmashell's colors lookups |
57,643 | 11 | 2,895 |
| plasmashell's total path syscalls | 70,355 | 12,670 | 15,573 |
| CPU time of the desktop session until idle | 16.0–16.2 s | 13.9–14.1 s | 14.0–14.3 s |
Quite nice imo.
peace~ <3