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

Fix performance issue in react-devtools when highlight enabled #18498

Merged
merged 3 commits into from
Apr 6, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,22 @@ function prepareToDraw(): void {
redrawTimeoutID = null;

const now = getCurrentTime();
let earliestExpiration = Number.MAX_VALUE;
let expirationTimeout = Number.NEGATIVE_INFINITY;

// Remove any items that have already expired.
nodeToData.forEach((data, node) => {
if (data.expirationTime < now) {
nodeToData.delete(node);
} else {
earliestExpiration = Math.min(earliestExpiration, data.expirationTime);
expirationTimeout = Math.max(expirationTimeout, data.expirationTime);
Faelivrinx marked this conversation as resolved.
Show resolved Hide resolved
}
});

draw(nodeToData);

redrawTimeoutID = setTimeout(prepareToDraw, earliestExpiration - now);
if (expirationTimeout > 0) {
redrawTimeoutID = setTimeout(prepareToDraw, expirationTimeout - now);
}
}

function measureNode(node: Object): Rect | null {
Expand Down