Skip to content
Snippets Groups Projects
Commit 987b4076 authored by Simon Barner's avatar Simon Barner
Browse files

- getValues(): cache AnnotationEntry list returned for given model element,...

- getValues(): cache AnnotationEntry list returned for given model element, significantly improving the performance of the AnnotationView for larger model. The view makes extensive use of this method from its update() method.
refs 1841
parent ec83c1a0
Branches
Tags
No related merge requests found
......@@ -61,6 +61,10 @@ public class AnnotationValueService extends
Map<Class<?>, List<IAnnotationValueProvider<IAnnotatedSpecification>>> valueProviderCache =
new HashMap<Class<?>, List<IAnnotationValueProvider<IAnnotatedSpecification>>>();
/** Cache to lookup {@link AnnotationEntry}s for {@link IModelElement}s. */
Map<IModelElement, List<AnnotationEntry>> annotationEntryCache =
new HashMap<IModelElement, List<AnnotationEntry>>();
/**
*
*/
......@@ -134,12 +138,19 @@ public class AnnotationValueService extends
/** {@inheritDoc} */
@Override
public List<AnnotationEntry> getValues(final IModelElement element) {
List<AnnotationEntry> cachedResult = annotationEntryCache.get(element);
if(cachedResult != null) {
return cachedResult;
}
if(element == null) {
return Collections.emptyList();
}
final List<AnnotationEntry> result = new ArrayList<AnnotationEntry>();// Collections.emptyMap();
final List<IAnnotationValueProvider<IAnnotatedSpecification>> registeredHandlers =
getRegisteredHandlers(element.getClass());
final List<AnnotationEntry> result = new ArrayList<AnnotationEntry>();
if(registeredHandlers != null && !registeredHandlers.isEmpty()) {
KernelModelElementUtils.runAsCommand(element, new Runnable() {
......@@ -193,8 +204,10 @@ public class AnnotationValueService extends
}
}
});
return result;
}
annotationEntryCache.put(element, result);
return result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment