Community
Participate
Working Groups
Build: 2.1 RC2 Workspace.newResource has safety code to assert the number of segments: message = "Path must include project and resource name: " + path.toString(); Assert.isLegal(path.segmentCount() >= ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH , message); This will create several garbage objects on every pass (at least a string buffer, two char[], two strings). This method is a very critical performance path , so I recommend refactoring as: if (path.segmentCount() < ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH) { message = "Path must include project and resource name: " + path.toString(); Assert.isLegal(false, message); } This will completely avoid garbage when the path is valid (99.9% of the time). This will improve performance of: findMember, getFile, getFolder, getChildren, IResourceDelta.getResource, copy, move, refreshLocal, etc.
Good find. I know that at one point we made an effort to do this in other places but it looks like this guy was missed! Consider for RC3.
Also in this method should we be checking the length of the path being passed in for a project or is it ok just to grab the last segment no matter what the length?
The performance bug was actually introduced quite recently as a result of serviceability work. Previously, the assertion messages didn't provide the name of the path. When this was fixed, performance wasn't taken into consideration.
Fix for RC3.
Fix approved by KevinM and DJ. Fix reviewed by DJ and JohnA. Released.