-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Save identifier module after first getting #6827
Conversation
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
lib/MultiModule.js
Outdated
return `multi ${this.dependencies.map(d => d.request).join(" ")}`; | ||
if (this._identifier) return this._identifier; | ||
|
||
this._identifier = `multi ${this.dependencies |
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.
Could you compute this within the constructor?
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.
Why do you want to save it inside constructor instead of lazy compute?
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 did it this way on other module classes. Moreover, identifier
is computed at least once. There is no benefit to compute it lazily.
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 changed it in MultiModule.js
8991e8a
to
8c11da5
Compare
lib/ContextModule.js
Outdated
@@ -65,6 +67,7 @@ class ContextModule extends Module { | |||
} | |||
|
|||
identifier() { | |||
if (this._identifier) return this._identifier; | |||
let identifier = this.context; |
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.
Move identifier creation into constructor like with the MultiModule.
Move it into a _createIdentifier()
function and call this in the constructor.
@Connormiha Thanks for your update. I labeled the Pull Request so reviewers will review it again. @sokra Please review the new changes. |
Thanks |
What kind of change does this PR introduce?
Performance. Cache module identifier after first call.
Did you add tests for your changes?
No
If relevant, link to documentation update:
N/A
Summary
In some plugins we have sort modules function like this:
Method
identifier()
can be run many times while sorting. Each callidentifier()
calculates identifier from options. We can cache it to avoid repeated calculate.Does this PR introduce a breaking change?
No
Other information