Avoid the full ancestor chain walk when removing elements from the Project Explorer - #4260
Open
vogella wants to merge 2 commits into
Open
Avoid the full ancestor chain walk when removing elements from the Project Explorer#4260vogella wants to merge 2 commits into
vogella wants to merge 2 commits into
Conversation
getParent() passed the Object[] holder instead of its element to pipelineParent(), so whenever no pipelined overriding extension returned a parent, pipelineParent() handed that array back as the fallback and getParent() returned an Object[] rather than a parent element. pipelineParent() also started with a null suggestion, so the first pipelined provider was asked for a parent without being told the parent the overridden extension had already computed. Seed the suggestion with the current parent, which is what findParent() does on the equivalent getParents() path.
AbstractTreeViewer.getParentElement() prefers ITreePathContentProvider, so for the Common Navigator it calls getParents(), which compiles complete paths up to the root. Only the last segment of the first path is used, so every ancestor level above the immediate parent is computed and discarded, and each level asks every enabled content extension for a parent. With JDT enabled that runs JavaCore.create and hasJavaNature per level, which hit the workspace tree. AbstractTreeViewer.internalRemove() takes this branch for elements that have no widget, so deleting many never expanded files paid the full walk per element and froze the UI. Override getParentElement() to ask getParent() first and fall back to the inherited behaviour when it returns null.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Deleting many files below a collapsed project freezes the Project Explorer. AbstractTreeViewer.getParentElement prefers ITreePathContentProvider, so the Common Navigator answers through getParents, which compiles complete paths up to the root although only the last segment of the first path is ever used. Every ancestor level above the immediate parent is computed and discarded, and each level asks every enabled content extension for a parent, which with JDT enabled runs JavaCore.create and hasJavaNature against the workspace tree. AbstractTreeViewer.internalRemove takes that branch for elements that have no widget, so files that were never made visible pay the full walk one by one.
CommonViewer now asks getParent first and falls back to the inherited behaviour when it returns null, which confines the change to the Common Navigator instead of reordering the two content provider interfaces for every JFace client. The performance test added in #4259 reports 3.5ms against 18.6ms for 2000 files ten folders deep.
The first commit has to stay ahead of the second. getParent passed the Object[] holder rather than its element to pipelineParent, so whenever no pipelined overriding extension supplied a parent it handed that array back and getParent returned an Object[] instead of a parent element. pipelineParent also started from a null suggestion, so the first pipelined provider was never told the parent the overridden extension had already computed.