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

Replace boxing ArrayList in LassoSelectionBehavior, remove unnecessary array alloc #9223

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

h3xds1nz
Copy link
Contributor

@h3xds1nz h3xds1nz commented Jun 6, 2024

Description

Replaces boxing ArrayList with generic List<Point> with preallocated size of 4 as that's always gonna be filled in the least, and removes array allocation through usage of Span<Point> as a new return type.

In LassoHelper the function to match points finally runs an efficient foreach (as it was iterating over an array before).

Note that we could return ROS<Point> instead and iterate via value but this solution offers an additional performance without really introducing any real risks.

In total, this will run about 3x faster along with less than 50% of originally introduced allocations.

Customer Impact

Improved performance, decreased allocations.

Regression

None.

Testing

Build and benchmark only but there are no functional changes.

Risk

None.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested a review from a team as a code owner June 6, 2024 22:29
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Jun 6, 2024
@h3xds1nz h3xds1nz changed the title [LassoSelectionBehavior.cs] Replace boxing ArrayList, remove unnecessary array alloc Replace boxing ArrayList in LassoSelectionBehavior, remove unnecessary array alloc Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants