Add cache for GetApplicationBase#3969
Merged
daxian-dbw merged 3 commits intoPowerShell:masterfrom Jun 20, 2017
Merged
Conversation
daxian-dbw
reviewed
Jun 20, 2017
Member
There was a problem hiding this comment.
How about having an internal static property named DefaultPowerShellAppBase like this:
internal static string DefaultPowerShellAppBase { get; } = GetApplicationBase(DefaultPowerShellShellID);And then use this get-only property in places where GetApplicationBase(DefaultPowerShellShellID) is used.
Collaborator
Author
There was a problem hiding this comment.
Good catch!
Done.
Member
There was a problem hiding this comment.
With that getter-only property, you won't need this method.
Member
There was a problem hiding this comment.
With that getter-only property, you won't need to add this.
Member
|
@iSazonov Sorry about the late review 😦 |
Clean up code to use cached value s_GetApplicationBaseDefaultPowerShell
debbae4 to
b06e43a
Compare
daxian-dbw
reviewed
Jun 20, 2017
| if (DefaultPowerShellAppBase != null) | ||
| { | ||
| return DefaultPowerShellAppBase; | ||
| } |
Member
There was a problem hiding this comment.
This is a bit confusing -- looks like a recursion would happen even though it's not. I suggest removing this if block.
daxian-dbw
approved these changes
Jun 20, 2017
Collaborator
Author
|
@daxian-dbw Thanks for the code review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
We call Utils.GetApplicationBase() multiple times at startup and later so we need cache the one to exclude a reflection.
Fix
DefaultPowerShellAppBaseinUtils.cs.Additional considerations
Code that uses a ShellId from Context has not been changed, although it is only associated with the Windows PowerShell (FullCLR).