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

Reduce calls to updateState in review manager #482

Merged
merged 2 commits into from
Sep 14, 2018

Conversation

RMacfarlane
Copy link
Contributor

@RMacfarlane RMacfarlane commented Sep 14, 2018

Check if HEAD and remotes are the same before calling updateState. The equals check is a bit ugly, I didn't extract it out into a method because putting it in Repository would add another thing for Joao to have to implement

Fixes #429

&& oldHead.type === newHead.type
&& sameUpstream;

const sameRemotes = this._previousRepositoryState.remotes.length === this._repository.remotes.length
Copy link
Member

Choose a reason for hiding this comment

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

We may want to filter out remotes created for PR purpose first so a fresh checkout will only lead to one updateState, triggered by branch change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to hold off on making that change now, but I agree


if (!sameHead || !sameRemotes) {
this._previousRepositoryState = {
HEAD: Object.assign(this._repository.HEAD),
Copy link
Member

Choose a reason for hiding this comment

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

Is object duplication necessary here? this._previousRepositoryState will keep reference to the old HEAD as when this._repository status gets updated, we will create new objects for HEAD and remotes. Correct me if I miss any potential data leak.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, you're right, no need to duplicate

Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

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

👍 for reducing the status change handling. Only some tiny comments.

@RMacfarlane RMacfarlane merged commit 7a58197 into master Sep 14, 2018
@RMacfarlane RMacfarlane deleted the rmacfarlane/update-state branch September 14, 2018 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants