-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Make Select-String faster by not doing extra work #7673
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
PaulHigin
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
But shouldn't this also use the NoContextTracker?
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Line 1589 in e07214f
| _globalContextTracker = new ContextTracker(_preContext, _postContext); |
|
@PaulHigin You are right! |
|
@powercode Please address the CodeFactor issues, specifically in new code. |
|
@adityapatwardhan Do you want me to fix all it the file or just the new ones? Happy to do both, but more to review if I fix all of them. |
|
@powercode Fixing the CodeFactor issues for the code you added / changed should be sufficient. Thanks! |
Don't check if fileinfos are directories (they never are). Don't track context when context size is 0.
79d5af8 to
439728d
Compare
iSazonov
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.
Great work!
| return s_inputStream; | ||
| return _path; | ||
| } | ||
| get => !_pathSet ? s_inputStream : _path; |
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.
More readable:
get => _pathSet ? _path : s_inputStream; 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.
For sure - don't know what I was thinking :)
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.
| { | ||
| throw PSTraceSource.NewArgumentNullException("value"); | ||
| } | ||
| _includeStrings = value ?? throw PSTraceSource.NewArgumentNullException("value"); |
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.
We could use nameof(value).
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.
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Show resolved
Hide resolved
src/Microsoft.PowerShell.Commands.Utility/commands/utility/MatchString.cs
Show resolved
Hide resolved
|
@powercode Please address comments and we'll merge. |
|
@iSazonov I'll have a look this evening. |
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 revert the remove - we can not change a public contract.
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.
Should we change to comment to indicated that this isn't used anywhere?
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 think we shouldn't block the PR and please open new tracking Issue to get PowerShell Committee conclusion.
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 force-pushed the revert of the Filename property.
Also removing the non-referenced property FileName.
10d512e to
fe15a92
Compare
|
@powercode Thanks for great work! |
PR Summary
By not tracking context in the common case where Context size is 0, and by not checking if the full name of a FileInfo is a Directory, about 30% of the execution time is cut when piping files into Select-String.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests