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

Make IgnoreEmptyCollectionsContractResolver special case ICollection.Count check #1759

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Nov 25, 2024

When checked target is IEnumerable, it's highly likely to implement ICollection. ICollection.Count is basically free and doesn't require enumerator building and boxing.

Testing with https://github.com/martincostello/aspnetcore-openapi/tree/main/perf/TodoApp.Benchmarks configured to run against local sources.

master

3,273,252.20 ns

this PR:

3,064,969.34 ns

@lahma lahma merged commit c740804 into RicoSuter:master Nov 25, 2024
2 checks passed
@lahma lahma deleted the IgnoreEmptyCollectionsContractResolver-collection-check branch November 25, 2024 19:24
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