Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary allocation in RepaintCause::new #4146

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

valsteen
Copy link
Contributor

@valsteen valsteen commented Mar 8, 2024

Hi!

I'm using egui for the UI of a VST3/Clap plugin, and this kind of environment is rather picky on performance. I use assert_no_alloc to make sure the audio thread is never allocating. The audio thread may request a repaint of the GUI tho, and this is where a saw that it may allocate when tracing the repaint reason.

Turns out it's not necessary, Location::caller is 'static, so using a &'static str instead of a String in RepaintCause::file will just work, so this PR just does that.

@emilk emilk changed the title remove unnecessary allocation in RepaintCause::new Remove unnecessary allocation in RepaintCause::new Mar 12, 2024
@emilk emilk added performance Lower CPU/GPU usage (optimize) egui labels Mar 12, 2024
@emilk emilk merged commit c87bcc4 into emilk:master Mar 12, 2024
21 checks passed
@valsteen valsteen deleted the remove_allocation_repaintcause branch March 12, 2024 11:07
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
Hi!

I'm using egui for the UI of a VST3/Clap plugin, and this kind of
environment is rather picky on performance. I use
[assert_no_alloc](https://crates.io/crates/assert_no_alloc) to make sure
the audio thread is never allocating. The audio thread may request a
repaint of the GUI tho, and this is where a saw that it may allocate
when tracing the repaint reason.

Turns out it's not necessary, `Location::caller` is `'static`, so using
a `&'static str` instead of a `String` in `RepaintCause::file` will just
work, so this PR just does that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui performance Lower CPU/GPU usage (optimize)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants