You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RedirectRule: opportunity for performance improvement #28883
Have you done any profiling here? This is a class of issue that's unlikely to be addressed unless it shows up as significant in a CPU or memory profile.
HasValue is a similar string comparison (string.IsNullOrEmpty).
If you follow the PathString equality operator, you'll see that it's more than just string.IsNullOrEmpty. And then there's consistency with the rest of the codebase.
You're right about the string.Concat overload being used. It's string.Concat(string, string, string) - there are overloads up to 4 string arguments and the C# compiler prefers the implicit conversion and the overload with string argumetns.
However, the PathString addition operator doesn't apply because the type of the next argument is a sting, not a PathString. It should be, because it's not being encoded like the rest of the components.
However, the PathString addition operator doesn't apply because the type of the next argument is a sting, not a PathString. It should be, because it's not being encoded like the rest of the components.
Activity
Tratcher commentedon Dec 28, 2020
Have you done any profiling here? This is a class of issue that's unlikely to be addressed unless it shows up as significant in a CPU or memory profile.
HasValue is a similar string comparison (string.IsNullOrEmpty).
aspnetcore/src/Http/Http.Abstractions/src/PathString.cs
Lines 47 to 49 in e04dee0
Are you sure about the boxing? PathString has an implicit string converter that may kick in first. It also overrides the
+operator.aspnetcore/src/Http/Http.Abstractions/src/PathString.cs
Lines 454 to 455 in e04dee0
aspnetcore/src/Http/Http.Abstractions/src/PathString.cs
Lines 414 to 419 in e04dee0
paulomorgado commentedon Dec 28, 2020
If you follow the
PathStringequality operator, you'll see that it's more than juststring.IsNullOrEmpty. And then there's consistency with the rest of the codebase.You're right about the
string.Concatoverload being used. It'sstring.Concat(string, string, string)- there are overloads up to 4 string arguments and the C# compiler prefers the implicit conversion and the overload withstringargumetns.However, the
PathStringaddition operator doesn't apply because the type of the next argument is asting, not aPathString. It should be, because it's not being encoded like the rest of the components.Tratcher commentedon Dec 28, 2020
It also has an overload for PathString + string.
paulomorgado commentedon Dec 28, 2020
Got it!
But that means that
will end up being
Right?
One more string than it needs to be. If we accept that
newPath.Substring(0, split)is unavoidable.Tratcher commentedon Dec 28, 2020
Fair point. As you said,
UriHelper.BuildRelativewould address most of this.paulomorgado commentedon Dec 29, 2020
Are there any unit tests for this? If so, where?
paulomorgado commentedon Dec 29, 2020
Found! MiddlewareTests.cs