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

Optimize WCond and ReduceIndex implementations for improved performance and safety #2648

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pluveto
Copy link

@pluveto pluveto commented Nov 29, 2024

This PR introduces some optimizations to the WCond and ReduceIndex structs to enhance performance and improve code clarity.

Key Changes:

WCond:

  • Introduced some separate variables to streamline the matching process, enhancing readability and maintainability.
  • Refactored iterator chains within the Map2 implementation to be more efficient and expressive.

ReduceIndex:

  • Removed explicit Clone bounds since T: Copy and U: Copy implicitly include Clone.
  • Replaced iter_mut().enumerate() with for i in 0..dst_len loops to reduce iterator overhead and improve loop performance.
  • Obtained the destination vector pointer using dst_ptr = dst.spare_capacity_mut().as_mut_ptr() and used the write method to directly insert data. This approach is more explicit and avoids unnecessary type conversions.
  • Utilized indices directly within loops instead of creating additional variables.

Next Steps:

  • Similar optimizations to other structures.

Regards,

Zijing

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