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

Improve performance of events processing #27

Merged
merged 7 commits into from
Jun 2, 2020

Conversation

pdpino
Copy link
Collaborator

@pdpino pdpino commented May 25, 2020

  • Move events sorting to WeekView, to only sort them once
    • An eventsByDate object is created, with date as keys (in format "YYYY-MM-DD") and list of events as values
    • Then each Events component accesses the events from the same object, avoiding extra copies and sorting more than necessary
    • The sorting is performed over the list of events from the same day, which should be much less than the number of total events
  • Memoize functions in WeekView.render, to avoid re-calculations when not necessary
  • Make Events and Header PureComponents, to avoid extra re-renders
  • Create Times component to display time column (is a PureComponent to avoid extra re-renders)
  • In WeekView.scrollEnded only update the state if the date actually changes, to avoid an extra re-render
  • Other minor changes
    • Move variables in App.js to state, to ease testing process
    • Reuse calculateDaysArray() function

PS: in my use case, I have about 1500 events, and it was taking 3-5 seconds to load 😬
PS2: I realize these may be a lot of logic changes and you may not agree with them, but I needed to make these improvements for my use case ASAP, so I just applied them without discussing them first. I understand if you want to further improve them, or reject them at all 🙂

pdpino added 6 commits May 15, 2020 22:37
Disable event-pressing if no handler is passed
Fix typo in README.md
Move sorting to WeekView, to avoid sorting multiple times
Add memoization to the sorting process
Avoid double renders in Events Component
…native-week-view into refactor/preprocess-events-2
example/package.json Outdated Show resolved Hide resolved
@hoangnm
Copy link
Owner

hoangnm commented May 31, 2020

Impressive! Overall, everything is great, the logic to transform events array to object is neat and clean, this is really a better way. I only left one comment. Thanks a lot for the PR!

@hoangnm hoangnm merged commit e35d625 into hoangnm:master Jun 2, 2020
@pdpino pdpino deleted the refactor/preprocess-events-2 branch August 29, 2020 03:08
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