-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Further reduce string allocations #32929
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
Conversation
3813368
to
2232536
Compare
src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorCodeDocumentExtensions.cs
Show resolved
Hide resolved
...crosoft.AspNetCore.Mvc.Razor.Extensions/src/Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj
Show resolved
Hide resolved
{ | ||
@namespace = null; | ||
return false; | ||
} | ||
|
||
relativePath = NormalizePath(relativePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NormalizePath
turned \\
to /
. But turns out we were later splitting on either path separators so we can safely remove it.
src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/SourceLocationTracker.cs
Outdated
Show resolved
Hide resolved
{ | ||
@namespace = null; | ||
return false; | ||
} | ||
|
||
relativePath = NormalizePath(relativePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mentioned this earlier, there's a Split that happens later on that tokenizes on either path separator and we only ever look at the path segments. The normalization is kinda moot.
src/Razor/Microsoft.AspNetCore.Razor.Language/src/Extensions/DefaultTagHelperTargetExtension.cs
Outdated
Show resolved
Hide resolved
@@ -568,6 +568,60 @@ public void IndexOf_SearchOnlyInsideTheRange_IfStartAndCountAreProvided() | |||
Assert.Equal(-1, result); | |||
} | |||
|
|||
[Fact] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: let's add a note in StringSegment.cs
to explain why we're rolling out our own implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a doc comment to the type.
b8b246b
to
af9673d
Compare
a669f97
to
f93643b
Compare
This has been updated. |
Found a bunch of places that performed Substring and Split and replaced them with StringSegment. Didn't make a dent in the micro-benchmark but this feels like a low cost fix to consider.