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

avm1: Fix performance regression in BitmapData::pixels_rgba #4919

Merged
merged 1 commit into from
Jul 24, 2021

Conversation

relrelb
Copy link
Contributor

@relrelb relrelb commented Jul 23, 2021

It was regressed in #4822 when changed to use flat_map. But currently Rust emits suboptimal code for such case. For now use Vec::with_capacity manually to avoid unnecessary re-allocations.

It was regressed in ruffle-rs#4822 when changed to use `flat_map`. But
currently Rust emits suboptimal code for such case. For now use
`Vec::with_capacity` manually to avoid unnecessary re-allocations.
Copy link
Collaborator

@adrian17 adrian17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

FYI, on a side I'm making a bigger benchmark for a Rust issue about flat_map/flatten generating suboptimal code in general, not just for const-size arrays.

@adrian17
Copy link
Collaborator

(rust-lang/rust#87411)

@adrian17
Copy link
Collaborator

adrian17 commented Jul 24, 2021

Interesting takeaway from rust-lang/rust#87411 (comment) :

As for the original change, imho converting everything into an iterator probably is not more idiomatic and is likely less efficient especially when already working with slices, because it's relying on propagation of traits in the iterators which may not all be implemented, and also the compiler to optimize through more abstract levels.

With that in mind, do we want to keep the comment about converting to flat_map?

@Herschel Herschel merged commit 06fce44 into ruffle-rs:master Jul 24, 2021
@relrelb relrelb deleted the bitmap_data branch July 24, 2021 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants