Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipse-dev] New optimized resource visitor

In today's integration build (20030114), there is new API in the org.eclipse.core.resources plugin for performing optimized traversals of resource trees.  The optimization works by avoiding the creation of transient Path and IResource handles during the traversal of tree elements that you are not interested in visiting.  Instead, the visitor is given a resource proxy, from which various information can be obtained without any garbage being created.  The new API entry point is:

IResource.accept(IResourceProxyVisitor, int).

If you currently use IResourceVisitor, you should switch to the new API if any of the following is true:

 - your visitor is not interested in every resource in the subtree being visited (for example, you only care about folders, files ending in .xml, derived resources, etc.).

- your visitor only needs the simple resource name, or other simple information that is available from the resource proxy.

- your visitor is interested in the full resource path, but doesn't need access to the resource handle

If you don't already use IResourceVisitor, but you currently traverse significant subtrees using IContainer.members(), you may also benefit from switching to this new API.  One great example is code that traverses a subtree to count the number of resources in order to initialize a progress monitor (for example the method #countChildrenOf in most ExportOperation classes).  Some other spots that could see huge performance gains are LaunchManager.searchForFiles and SearchForBuildFilesDialog.searchForBuildFiles).

We are switching to use this visitor internally in the resources plugin, and we have seen speed improvements up to 22x over the old visitor implementation in the best case.  In the worst case, this visitor is still as fast as the old visitor, although slightly less convenient to use due to the extra indirection of the proxy.  From glancing through the senders of the old accept method, it looks like most existing resource visitors can take advantage of this.  If you have further questions, please send them to the platform-core-dev mailing list.

Eclipse Platform Core Team

Back to the top