Skip to content
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 Priority queue in chunk graph algorithm #8238

Closed
wants to merge 7 commits into from

Conversation

sokra
Copy link
Member

@sokra sokra commented Oct 18, 2018

What kind of change does this PR introduce?
algorithmic performance improvement

Did you add tests for your changes?
existing tests

Does this PR introduce a breaking change?
no

What needs to be documented once your changes are merged?
nothing

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

this.heap = [];
/** @type {function(T):number}*/
this.priorityFn = priorityFn;
for (let item of items) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since items is optional, you must use an if to guard the iteration

}
const poppedValue = this.heap.pop();
this._siftDown();
return poppedValue.item;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling dequeue on an empty PriorityQueue would result in a TypeError. It would be better to change this line to:

Suggested change
return poppedValue.item;
return poppedValue ? poppedValue.item : undefined;

@sokra
Copy link
Member Author

sokra commented Oct 23, 2018

No longer needed because of #8242

@sokra sokra closed this Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants