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

Only update phrases object when the focusedInput actually changes. #448

Merged
merged 1 commit into from
Apr 14, 2017

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Apr 14, 2017

Realized this when I was prototyping some perf changes... but basically the modifiers object is not the only one that is changing (unnecessarily) on every render.

to: @moonboots @ljharb @airbnb/webinfra

@majapw majapw force-pushed the maja-fix-phrases-calendarday-rerendering branch from 9dbbb05 to 99f9863 Compare April 14, 2017 05:51
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

Test coverage? :-)

@majapw
Copy link
Collaborator Author

majapw commented Apr 14, 2017

@ljharb I'm not entirely sure how to test this, especially given that it is in componentWillReceiveProps

@coveralls
Copy link

coveralls commented Apr 14, 2017

Coverage Status

Coverage decreased (-0.8%) to 83.1% when pulling 99f9863 on maja-fix-phrases-calendarday-rerendering into 782b5f3 on master.

@ljharb
Copy link
Member

ljharb commented Apr 14, 2017

@majapw wrapper.instance().componentWillReceiveProps, unless .setProps() works

@coveralls
Copy link

coveralls commented Apr 14, 2017

Coverage Status

Coverage decreased (-0.8%) to 83.1% when pulling 99f9863 on maja-fix-phrases-calendarday-rerendering into 782b5f3 on master.

@majapw majapw force-pushed the maja-fix-phrases-calendarday-rerendering branch from 99f9863 to b40b5d6 Compare April 14, 2017 16:24
@majapw
Copy link
Collaborator Author

majapw commented Apr 14, 2017

Added some tests! 🎉

};

describe('neither props.focusedInput nor props.phrases have changed', () => {
it('state.phrases does not change', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to actually write a test here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did. I just forgot. :P

@majapw majapw force-pushed the maja-fix-phrases-calendarday-rerendering branch from b40b5d6 to 062db26 Compare April 14, 2017 16:36

if (focusedInput !== this.props.focusedInput || phrases !== this.props.phrases) {
// set the appropriate CalendarDay phrase based on focusedInput
let chooseAvailableDate = phrases.chooseAvailableDate;
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use destructuring here if you like.

@ljharb ljharb added the semver-patch: fixes/refactors/etc Anything that's not major or minor. label Apr 14, 2017
@coveralls
Copy link

coveralls commented Apr 14, 2017

Coverage Status

Coverage increased (+0.05%) to 83.961% when pulling b40b5d6 on maja-fix-phrases-calendarday-rerendering into 782b5f3 on master.

@coveralls
Copy link

coveralls commented Apr 14, 2017

Coverage Status

Coverage increased (+0.05%) to 83.961% when pulling 062db26 on maja-fix-phrases-calendarday-rerendering into 782b5f3 on master.

@lencioni
Copy link
Contributor

Just curious, did you measure the performance impact of this change?

@majapw
Copy link
Collaborator Author

majapw commented Apr 14, 2017

@lencioni this change on its own will not have any performance impact due to the fact that each CalendarDay will still be updated on every hover or mouse interaction because modifiers gets rebuilt in every render at the top-level. However, I have been working on rearchitecturing modifiers pretty much entirely in a separate change and the combination of the two will lead to a huge speed-up.

@majapw majapw merged commit 3815516 into master Apr 14, 2017
@majapw majapw deleted the maja-fix-phrases-calendarday-rerendering branch April 14, 2017 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch: fixes/refactors/etc Anything that's not major or minor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants