From 10dab495f296fcef5a8b6afb380e91c57c134d59 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Wed, 10 Jul 2013 14:45:11 -0700 Subject: [PATCH] Stop Unnecessary Purging of Node Cache When each component unmounts, it already cleans up its respective entry in the node cache. Let's stop blowing away the entire node cache unnecessarily. This should improve performance because a React component's root will never need to be searched for more than once. --- src/core/ReactDOMIDOperations.js | 2 -- src/core/ReactID.js | 8 -------- 2 files changed, 10 deletions(-) diff --git a/src/core/ReactDOMIDOperations.js b/src/core/ReactDOMIDOperations.js index 8f39858821..a0ddd01720 100644 --- a/src/core/ReactDOMIDOperations.js +++ b/src/core/ReactDOMIDOperations.js @@ -161,7 +161,6 @@ var ReactDOMIDOperations = { dangerouslyReplaceNodeWithMarkupByID: function(id, markup) { var node = ReactID.getNode(id); DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup); - ReactID.purgeEntireCache(); }, /** @@ -171,7 +170,6 @@ var ReactDOMIDOperations = { manageChildrenByParentID: function(parentID, domOperations) { var parent = ReactID.getNode(parentID); DOMChildrenOperations.manageChildren(parent, domOperations); - ReactID.purgeEntireCache(); } }; diff --git a/src/core/ReactID.js b/src/core/ReactID.js index d677b14e8a..e8c34db031 100644 --- a/src/core/ReactID.js +++ b/src/core/ReactID.js @@ -158,16 +158,8 @@ function purgeID(id) { delete nodeCache[id]; } -/** - * Clears the entire cache. - */ -function purgeEntireCache() { - nodeCache = {}; -} - exports.ATTR_NAME = ATTR_NAME; exports.getID = getID; exports.setID = setID; exports.getNode = getNode; exports.purgeID = purgeID; -exports.purgeEntireCache = purgeEntireCache;