зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1238941 - Remove caching in devtools tree widget (react). r=fitzgen
--HG-- extra : source : 3cea1d886e9e6861a8720de42825185381a208a3
This commit is contained in:
Родитель
f03153fe8c
Коммит
e337d68642
|
@ -209,9 +209,6 @@ const DominatorTree = module.exports = createClass({
|
|||
getKey: node =>
|
||||
node instanceof DominatorTreeLazyChildren ? node.key() : node.nodeId,
|
||||
itemHeight: TREE_ROW_HEIGHT,
|
||||
// We can't cache traversals because incremental fetching of children
|
||||
// means the traversal might not be valid.
|
||||
reuseCachedTraversal: _ => false,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -166,10 +166,6 @@ const Tree = module.exports = createClass({
|
|||
onFocus: PropTypes.func,
|
||||
// The depth to which we should automatically expand new items.
|
||||
autoExpandDepth: PropTypes.number,
|
||||
// A predicate that returns true if the last DFS traversal that was cached
|
||||
// can be reused, false otherwise. The predicate function is passed the
|
||||
// cached traversal as an array of nodes.
|
||||
reuseCachedTraversal: PropTypes.func,
|
||||
// Optional event handlers for when items are expanded or collapsed.
|
||||
onExpand: PropTypes.func,
|
||||
onCollapse: PropTypes.func,
|
||||
|
@ -178,7 +174,6 @@ const Tree = module.exports = createClass({
|
|||
getDefaultProps() {
|
||||
return {
|
||||
autoExpandDepth: AUTO_EXPAND_DEPTH,
|
||||
reuseCachedTraversal: null,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -187,7 +182,6 @@ const Tree = module.exports = createClass({
|
|||
scroll: 0,
|
||||
height: window.innerHeight,
|
||||
seen: new Set(),
|
||||
cachedTraversal: undefined,
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -329,23 +323,12 @@ const Tree = module.exports = createClass({
|
|||
* Perform a pre-order depth-first search over the whole forest.
|
||||
*/
|
||||
_dfsFromRoots(maxDepth = Infinity) {
|
||||
const cached = this.state.cachedTraversal;
|
||||
if (cached
|
||||
&& maxDepth === Infinity
|
||||
&& this.props.reuseCachedTraversal
|
||||
&& this.props.reuseCachedTraversal(cached)) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const traversal = [];
|
||||
|
||||
for (let root of this.props.getRoots()) {
|
||||
this._dfs(root, maxDepth, traversal);
|
||||
}
|
||||
|
||||
if (this.props.reuseCachedTraversal) {
|
||||
this.state.cachedTraversal = traversal;
|
||||
}
|
||||
|
||||
return traversal;
|
||||
},
|
||||
|
||||
|
@ -365,10 +348,6 @@ const Tree = module.exports = createClass({
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setState({
|
||||
cachedTraversal: null,
|
||||
});
|
||||
}),
|
||||
|
||||
/**
|
||||
|
@ -380,10 +359,6 @@ const Tree = module.exports = createClass({
|
|||
if (this.props.onCollapse) {
|
||||
this.props.onCollapse(item);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
cachedTraversal: null,
|
||||
});
|
||||
}),
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче