зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1653779 - Lazily create parent map r=nchevobbe,bomsy
parentMap appears to only be used when pressing the left arrow key to navigate to the parent folder in the source tree. If this is too slow it could be replaced with a traverseTree search. Differential Revision: https://phabricator.services.mozilla.com/D115318
This commit is contained in:
Родитель
cf732621d4
Коммит
93d857cb3c
|
@ -220,7 +220,7 @@ class SourcesTree extends Component {
|
|||
renderTree() {
|
||||
const { expanded, focused, projectRoot } = this.props;
|
||||
|
||||
const { highlightItems, listItems, parentMap, sourceTree } = this.state;
|
||||
const { highlightItems, listItems, getParent, sourceTree } = this.state;
|
||||
|
||||
const treeProps = {
|
||||
autoExpandAll: false,
|
||||
|
@ -228,7 +228,7 @@ class SourcesTree extends Component {
|
|||
expanded,
|
||||
focused,
|
||||
getChildren: getChildren,
|
||||
getParent: item => parentMap.get(item),
|
||||
getParent,
|
||||
getPath: this.getPath,
|
||||
getRoots: () => this.getRoots(sourceTree, projectRoot),
|
||||
highlightItems,
|
||||
|
|
|
@ -99,10 +99,18 @@ export function updateTree({
|
|||
|
||||
const newSourceTree = collapseTree(uncollapsedTree);
|
||||
|
||||
let lazyParentMap;
|
||||
const getParent = function(key) {
|
||||
if (!lazyParentMap) {
|
||||
lazyParentMap = createParentMap(newSourceTree);
|
||||
}
|
||||
return lazyParentMap.get(key);
|
||||
};
|
||||
|
||||
return {
|
||||
uncollapsedTree,
|
||||
sourceTree: newSourceTree,
|
||||
parentMap: createParentMap(newSourceTree),
|
||||
getParent,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче