-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Use span-based overloads #11884
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToString() here results in an allocation, can we just update that method to accept a readonlyspan?
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.
No, it is used then in class ctor-s.
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.
ReadOnlySpan<char> typically is an implicit cast from string, isn't it?
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.
@vexx32 No, only string -> ReadOnlySpan
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
SteveL-MSFT
left a comment
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.
LGTM
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.
Please use multiple statements for better readability, like
var filterSpan = filter.AsSpan(0, filter.Length - 2);
return commandName.AsSpan().Contains(filterSpan, StringComparison.OrdinalIgnoreCase);
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.
Fixed.
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.
same here :)
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.
Fixed.
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.