| Summary: | performance: ModelManagerImpl performs unnecessary work | ||
|---|---|---|---|
| Product: | [WebTools] WTP Source Editing | Reporter: | David Slubicki <slubicki> |
| Component: | wst.sse | Assignee: | 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: | |||
*** This bug has been marked as a duplicate of 149851 *** 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. |
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.