Skip to content

Optimize tray icon name handling with OsString and Cow#537

Merged
MalpenZibo merged 1 commit intoMalpenZibo:mainfrom
romanstingler:tray-optimize
Mar 23, 2026
Merged

Optimize tray icon name handling with OsString and Cow#537
MalpenZibo merged 1 commit intoMalpenZibo:mainfrom
romanstingler:tray-optimize

Conversation

@romanstingler
Copy link
Collaborator

related to #529

I fixed the tray icon memory consumption because it was making way too many small allocations and slowing everything down. Now the code uses OsString for the paths and I added Cow for the strings so we don't copy data unless we really have to.
The normalization part is also much faster now because if the string is already good it just leaves it alone, plus I added a LazyLock cache so we don't calculate the same icon names over and over. I also fixed the prefix matching to stop making temporary Vec lists while it looks at characters and it just stops early if it finds an exact match.

All the Vec allocations use with_capacity now because we already know the size, so the computer doesn't have to keep moving memory around while the code is running in the hot path.

It is already late, maybe I overlooked a few things but this makes things better than before

@MalpenZibo MalpenZibo merged commit 54575c9 into MalpenZibo:main Mar 23, 2026
4 checks passed
@romanstingler romanstingler deleted the tray-optimize branch March 24, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants