Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Prevent unecessary renders#4735

Merged
codehag merged 1 commit into
firefox-devtools:masterfrom
jasonLaster:perf-10
Nov 20, 2017
Merged

Prevent unecessary renders#4735
codehag merged 1 commit into
firefox-devtools:masterfrom
jasonLaster:perf-10

Conversation

@jasonLaster

Copy link
Copy Markdown
Contributor

Fixes #4692

Summary of Changes

  • the JSX patch introduced sourceMetaData, which when not set would be a new empty object every time, this fixes that by sharing the same object.
  • i think it can be a bit cleaner

Testing

I'd like to add a unit test that adds a source and checks to make sure the editor did not render.

@James300

Copy link
Copy Markdown
Contributor

This is a really cool optimization for making sure React doesn't think things have changed 😄

Comment thread src/reducers/ast.js
const emptySourceMetaData = {};
export function getSourceMetaData(state: OuterState, sourceId: string) {
return state.ast.getIn(["sourceMetaData", sourceId]) || {};
return state.ast.getIn(["sourceMetaData", sourceId]) || emptySourceMetaData;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i bet getIn takes a default arg

@codehag

codehag commented Nov 20, 2017

Copy link
Copy Markdown
Contributor

looks good!

@codehag codehag merged commit 7a4628c into firefox-devtools:master Nov 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance regression when loading sources

3 participants