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

Refactor TestAssert: Replace ToArray()[0] with First() for efficiency. #4888

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

Saurav-shres
Copy link
Contributor

@Saurav-shres Saurav-shres commented Nov 23, 2024

This pull request refactors the TestAssert class, specifically the IsRunnable(Type type, string name, ResultState resultState) method. The change replaces the use of ToArray()[0] with the more efficient First() method from LINQ. This improves the performance by eliminating unnecessary array allocation and directly accessing the first element in the collection.

Fixes #4886

@Saurav-shres
Copy link
Contributor Author

@dotnet-policy-service agree

Copy link
Member

@stevenaw stevenaw left a comment

Choose a reason for hiding this comment

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

Looks great to me, and all the tests are passing. Thanks for spotting this and for your contribution to fixing it @Saurav-shres

@stevenaw stevenaw merged commit 6e14a0f into nunit:main Nov 23, 2024
5 checks passed
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.

Optimize ToArray()[0] with First() in TestAssert class in TestAssert.cs
2 participants