Bug 35131 - Optimize source attachment query when no source attachment available
Summary: Optimize source attachment query when no source attachment available
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 RC3   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-17 07:07 EST by Jerome Lanneluc CLA
Modified: 2003-03-20 06:56 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 Jerome Lanneluc CLA 2003-03-17 07:07:53 EST
Build RC2

As shown in bug 34008, we never remember that a package fragment root has no 
source attachment. Thus we try to find a source attachment recommendation for 
each query to getSourceAttachmentPath() and getSourceAttachmentRootPath()
Comment 1 Jerome Lanneluc CLA 2003-03-17 07:18:08 EST
Proposed fix on PackageFragmentRoot:
- Add constant: protected final static String NO_SOURCE_ATTACHEMENT = ""; //
$NON-NLS-1$
- Change getSourceAttachmentProperty() to:
/**
 * Returns the server property for this package fragment root's
 * source attachement.
 */
protected String getSourceAttachmentProperty() throws JavaModelException {
	String propertyString = null;
	QualifiedName qName= getSourceAttachmentPropertyName();
	try {
		propertyString = ResourcesPlugin.getWorkspace().getRoot
().getPersistentProperty(qName);
		
		// if no existing source attachment information, then lookup a 
recommendation from classpath entries
		if (propertyString == null) {
			IClasspathEntry recommendation = 
findSourceAttachmentRecommendation();
			if (recommendation != null) {
				IPath rootPath = 
recommendation.getSourceAttachmentRootPath();
				propertyString = 
					recommendation.getSourceAttachmentPath
().toString() 
						+ ((rootPath == null) 
							? "" : //$NON-NLS-1$
						
	(ATTACHMENT_PROPERTY_DELIMITER + rootPath.toString())); 
				setSourceAttachmentProperty(propertyString);
			} else {
				// mark as being already looked up
				setSourceAttachmentProperty
(NO_SOURCE_ATTACHEMENT);
			}
		} else if (NO_SOURCE_ATTACHEMENT.equals(propertyString)) {
			// already looked up and no source attachment found
			return null;
		}
		return propertyString;
	} catch (CoreException ce) {
		throw new JavaModelException(ce);
	}
}
Comment 2 Philipe Mulet CLA 2003-03-17 07:34:52 EST
Nice simple optimization fix for a performance release... 
Would like to get approval for RC3.
Comment 3 Olivier Thomann CLA 2003-03-17 08:46:30 EST
NO_SOURCE_ATTACHEMENT could be used instead of "" in the code:
propertyString = 
recommendation.getSourceAttachmentPath
().toString() 
	+ ((rootPath == null) 
		? "" : //$NON-NLS-1$
...

Would you have a test case that would allow me to check that this change
improves the performance.
Comment 4 Jerome Lanneluc CLA 2003-03-17 09:02:01 EST
You can use the test case described in bug 34008.
Comment 5 Philipe Mulet CLA 2003-03-18 04:42:58 EST
Got approval for RC3
Comment 6 Jerome Lanneluc CLA 2003-03-18 05:03:20 EST
Fix released to HEAD.
Comment 7 David Audel CLA 2003-03-20 06:56:29 EST
Verified.