Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 150504

Summary: performance: ModelManagerImpl performs unnecessary work
Product: [WebTools] WTP Source Editing Reporter: David Slubicki <slubicki>
Component: wst.sseAssignee: David Williams <david_williams>
Status: CLOSED DUPLICATE QA Contact: David Williams <david_williams>
Severity: normal    
Priority: P3    
Version: 1.5   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description David Slubicki CLA 2006-07-13 09:29:25 EDT
Some of the "get*Model*" methods perform unnecessary work if a model already exists.  

Example:
The following three (abbreviated) methods provide one path to acquiring a model:


public synchronized IStructuredModel getModelForEdit(IFile iFile){
     return _commonGetModel(iFile, EDIT, null, null);
}


private IStructuredModel _commonGetModel(IFile iFile, ReadEditType rwType, String encoding, String lineDelimiter)
     { 
	String id = calculateId(iFile);
	IModelHandler handler = calculateType(iFile);
	URIResolver resolver = calculateURIResolver(iFile);
	IStructuredModel model = _commonGetModel(iFile, id, handler, resolver,   rwType, encoding, lineDelimiter);
	return model;
     }


private IStructuredModel _commonGetModel(IFile file, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, String encoding, String lineDelimiter) 
     {
	IStructuredModel model = null;
	if (file != null && file.exists()) {
             SharedObject sharedObject = (SharedObject) fManagedObjects.get(id);
	     if (sharedObject == null) {
		// model created here
	     } else {
		_incrCount(sharedObject, rwType);
	     }
	     model= (model!= null)? model = sharedObject.theSharedModel : null;
	}
	return model;
     }


Notice the unnecessary calculations being done in the second method.  These calculations should only be performed if a model doesn't already exist in the cache, as the computed values are never used otherwise.

The call to: "calculateType(iFile);" appears to be expensive sometimes, so it would be nice to avoid it if possible.
Comment 1 Nitin Dahyabhai CLA 2006-07-18 04:42:41 EDT

*** This bug has been marked as a duplicate of 149851 ***
Comment 2 John Lanuti CLA 2006-11-28 15:49:07 EST
This is part of a mass update to close out all stale WTP bugs which are in the resolved state without an appropriate targeted version.  If you feel this bug was closed inappropriately, please reopen.