-
Notifications
You must be signed in to change notification settings - Fork 0
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
OR: performance tune Match function [PLAT-23274] #2
base: master
Are you sure you want to change the base?
Conversation
Some Perf stats on this change: Gen0 collections collections completely eliminated |
src/OpenRasta/UriTemplate.cs
Outdated
|
||
var cullCount = 0; | ||
foreach (var baseUriSegment in baseSegments) | ||
if (RemoveTrailingSlash(baseUriSegment) == candidateSegments[cullCount]) |
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.
Could the RemoveTrailingSlash
call be moved into the UriTemplateTable.Match()
method here so that we don't need to trim each segment for each possible UriTemplate
instance?
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.
Additionally, could the RemoveTrailingSlash
call be simplified to just baseUriSegment.TrimEnd('/')
?
public Collection<UriTemplateMatch> Match(Uri uri) | ||
{ | ||
var lastMaxLiteralSegmentCount = 0; | ||
var matches = new Collection<UriTemplateMatch>(); | ||
foreach (var template in KeyValuePairs) | ||
if (BaseAddress != null) |
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.
If I'm reading this right, if BaseAddress
is null
then no URL will ever find a match. Should BaseAddress
be validated to not be null
when initializing the UriTemplateTable
instance?
{ | ||
case SegmentType.Literal when | ||
string.CompareOrdinal(candidateSegment.ProposedSegment.Text, candidateSegment.UnescapedText) != 0: | ||
string.CompareOrdinal(_segments[i].Text, unescapedText) != 0: |
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.
Not your code but this could be simplified to !string.Equals(_segments[i].Text, unescapedText, StringComparison.OrdinalIgnoreCase)
.
Hi there!
Thank you so much for contributing this pull request. We love when the community
steps up and share, and we're enormously thankful.
You don't have to do all of those following things, they are what we try and get
done for code coming in:
CHANGELOG.md
project
, or scenarios in theTestRig
.master
If those are needed, and you haven't and can't, we thank you enormously for your
contribution, and we'll add those before merging the pull request.
Thanks!
The OpenRasta community