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

Benchmarks, a few minor optimizations, 5% perf gain #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nyurik
Copy link

@nyurik nyurik commented Oct 13, 2023

  • Add a benchmark that uses all image sizes (ignoring the image data itself)
  • This change gets 5% boost in my testing
  • bumps the edition to 2021
  • adds a few Debug traits
  • made leaf_contains_rect and split_tree not use self due to borrowing rules - easier to separate them. Perhaps Nodes could even be made into its own separate struct, as it does not need to reference anything outside of it.

This removes all `T: Clone` requirements, and instead the Packer will store readonly references. References can be freely copied as needed, so no issues there. I think this is a better approach because the primary usecase of this lib is to later substitute rectangles with some data, like pixels, and cloning that is expensive.`

This PR also:
* bumps the edition to 2021
* adds a few Debug traits
* made `leaf_contains_rect` and `split_tree` not work on `self` due to borrowing rules - easier to separate them. Perhaps `Nodes` could even be made into its own separate struct, as it does not need to reference anything outside of it.
This removes all `T: Clone` requirements, and instead the Packer will store readonly references. References can be freely copied as needed, so no issues there. I think this is a better approach because the primary usecase of this lib is to later substitute rectangles with some data, like pixels, and cloning that is expensive.`

This PR also:
* bumps the edition to 2021
* use `Option<T>` instead of `Result<T, ()>`
* A bit of a doc fix
* A minor optimization for iteration
* adds a few Debug traits
* made `leaf_contains_rect` and `split_tree` not work on `self` due to borrowing rules - easier to separate them. Perhaps `Nodes` could even be made into its own separate struct, as it does not need to reference anything outside of it.
@nyurik nyurik changed the title Use references instead of Clone Benchmarks, a few minor optimizations, 5% perf gain Oct 14, 2023
@nyurik
Copy link
Author

nyurik commented Oct 21, 2023

@ChevyRay hi, a friendly ping - let me know if anything else is needed here and in other PRs. Thanks!!

@nyurik
Copy link
Author

nyurik commented Aug 28, 2024

hi, a friendly ping when you have a sec? Thx!

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.

1 participant