Skip to content

Cache HtmlContentBuilder's Entries' count for loops #23707

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

Merged
merged 1 commit into from
Jul 8, 2020

Conversation

martincostello
Copy link
Member

Cache the value of Entries.Count into a local when enumerating loops, rather than re-evaluating on each iteration.

I've seen this approach used elsewhere in the code base for performance, and as this type is used as part of MVC view rendering I figured it would be worth the tweak.

The type itself doesn't have any micro-benchmarks, so I wasn't sure what to use to get some concrete numbers on before/after.

Cache the value of Entries.Count into a local when enumerating loops, rather than re-evaluating on each pass.
@mkArtakMSFT mkArtakMSFT added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jul 8, 2020
Copy link
Contributor

@mkArtakMSFT mkArtakMSFT left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, @martincostello.

@mkArtakMSFT mkArtakMSFT merged commit 769fc6d into dotnet:master Jul 8, 2020
@martincostello martincostello deleted the Cache-Entries-Count branch July 8, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants