Bug 34139 - Workspace.newResource should avoid eager message binding
Summary: Workspace.newResource should avoid eager message binding
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC3   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2003-03-07 15:27 EST by John Arthorne CLA
Modified: 2003-03-11 18:05 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2003-03-07 15:27:37 EST
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.
Comment 1 DJ Houghton CLA 2003-03-07 16:15:10 EST
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.
Comment 2 DJ Houghton CLA 2003-03-07 16:23:05 EST
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?
Comment 3 John Arthorne CLA 2003-03-10 09:53:47 EST
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.
Comment 4 DJ Houghton CLA 2003-03-11 15:44:44 EST
Fix for RC3.
Comment 5 John Arthorne CLA 2003-03-11 18:05:10 EST
Fix approved by KevinM and DJ. Fix reviewed by DJ and JohnA.  Released.