-
Notifications
You must be signed in to change notification settings - Fork 9
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
create_box_gauss() allocates needlessly #9
Comments
I'd wait for const generics. Const generics are coming pretty soon, I'm not sure how Iterators would solve the problem - you need at least one allocation (for the new, blurred image) and one allocation for the backbuffer. |
Oh, the backbuffer is still needed. I'm talking about this allocation: Line 32 in 3abecde
|
yeah, that could just be: 0..n.map(|i| if i < m { wl } else { wu }).collect(); I haven't worked on this crate in a long time, I just did this as a hobby at first. |
The trait you want to return in this case is |
Well, for |
create_box_gauss()
currently returns aVec<i32>
with length specified by the input parametern
. Vectors are always allocated on the heap, which is costly. Even the tiny vectors of 3 elements add 3% to the total runtime, or 6% in asymmetric case that calculates the box twice.Sadly const generics are not yet implemented in rustc so we cannot abstract it over the length of a slice, but we can work around this e.g. by returning an iterator.
The text was updated successfully, but these errors were encountered: