Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -1870,14 +1870,14 @@ public ResourceInfo getResourceInfo(IPath path, boolean phantom, boolean mutable
Assert.isNotNull(info, "Tree root info must never be null"); //$NON-NLS-1$
return info;
}
ResourceInfo result = null;
if (!tree.includes(path)) {
return null;
}
ResourceInfo result;
if (mutable) {
if (!tree.includes(path)) {
return null;
}
result = (ResourceInfo) tree.openElementData(path);
} else {
result = (ResourceInfo) tree.getElementData(path);
result = (ResourceInfo) tree.getElementDataOrNull(path);
}
if (result != null && (!phantom && result.isSet(M_PHANTOM))) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,26 @@ public DeltaDataTree getDataTree() {
return tree;
}

/**
* Returns the element data for the given element identifier, or
* <code>null</code> if the element is not present in this tree.
* <p>
* Unlike {@link #includes(IPath)} followed by {@link #getElementData(IPath)}
* this performs at most one tree lookup.
*/
public Object getElementDataOrNull(IPath key) {
if (key.isRoot()) {
return null;
}
synchronized (this) {
DataTreeLookup lookup = lookupCache; // Grab it in case it's replaced concurrently.
if (lookup == null || lookup.key != key) {
lookupCache = lookup = tree.lookup(key);
}
return lookup.isPresent ? lookup.data : null;
}
}

/**
* Returns the element data for the given element identifier.
* The given element must be present in this tree.
Expand Down
Loading