Use span-based overloads#11884
Conversation
src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/ModuleViewModel.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
ToString() here results in an allocation, can we just update that method to accept a readonlyspan?
There was a problem hiding this comment.
No, it is used then in class ctor-s.
There was a problem hiding this comment.
ReadOnlySpan<char> typically is an implicit cast from string, isn't it?
There was a problem hiding this comment.
@vexx32 No, only string -> ReadOnlySpan
There was a problem hiding this comment.
Right, so if the method parameter is currently using string we should be able to change it to ReadOnlySpan<char> and have the implicit cast handle it, shouldn't we? Or am I missing some context here? 🙂
There was a problem hiding this comment.
I missing some context here
CreateParameterWithArgument() passes the string to a constructor so it makes no sense to convert to span here.
|
Added new commit. |
src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Management.UI.Internal/ShowCommand/ViewModel/CommandViewModel.cs
Outdated
Show resolved
Hide resolved
2627a51 to
372c510
Compare
372c510 to
3e3fad1
Compare
There was a problem hiding this comment.
Please use multiple statements for better readability, like
var filterSpan = filter.AsSpan(0, filter.Length - 2);
return commandName.AsSpan().Contains(filterSpan, StringComparison.OrdinalIgnoreCase);
3e3fad1 to
5d7aeed
Compare
|
🎉 Handy links: |
PR Summary
PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.