Skip to content

Conversation

@ToddGrun
Copy link
Contributor

…ase.TrySplitNamespaceAndType

This method allocated multiple strings on every invocation when they were rarely needed. With this change, I see a reduction in memory allocated during RazorProjectEngine.ProcessDesignTime of 1.4%.

…ase.TrySplitNamespaceAndType

This method allocated multiple strings on every invocation when they were rarely needed. With this change, I see a reduction in memory allocated during RazorProjectEngine.ProcessDesignTime of 1.4%.
@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jun 12, 2020
typeName = GetTextSpanContent(typeNameTextSpan, typeName);
}
if (!TrySplitNamespaceAndType(typeName, out var _, out var className))
if (!TrySplitNamespaceAndType(typeName, out var _, out var classNameTextSpan))
Copy link
Contributor

@dougbu dougbu Jun 12, 2020

Choose a reason for hiding this comment

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

Minor but this method could exit earlier if the original typeName were empty. No reason to get the string content of an empty span. #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to affect the functionality of this code, as there are some subtle behaviors here. Let me know if you think it's worth pursuing.


In reply to: 439606336 [](ancestors = 439606336)

Copy link
Contributor

Choose a reason for hiding this comment

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

Not my code. I defer to other reviewers 😺

Copy link
Contributor

@ajaybhargavb ajaybhargavb left a comment

Choose a reason for hiding this comment

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

🎉


// Internal for testing.
internal static bool TrySplitNamespaceAndType(string fullTypeName, out string @namespace, out string typeName)
internal static bool TrySplitNamespaceAndType(string fullTypeName, out TextSpan @namespace, out TextSpan typeName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@ToddGrun ToddGrun merged commit b13cb76 into master Jun 12, 2020
@ToddGrun ToddGrun deleted the dev/toddgrun/TrySplitNamespaceAndTypeAllocatesTooMuch branch June 12, 2020 20:18
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.

5 participants