Community
Participate
Working Groups
The method DAnalysisSessionImpl.getSelectedViewpoints(boolean) is relatively costly, involing the creation of an ordered TreeSet based on a Comparator which does non-trivial work. It is not obvious to callers that such an innocent-looking getter method is costly, and thus it is sometimes called in loops (for example in oViewpointSelectionCallback.selectViewpoint(Viewpoint, Session, boolean, IProgressMonitor)). The actual value only changes very rarely, we should see if it can not be cached, and recomputed only when needed (maybe even incrementaly). In addition, obvious cases where callers invoke it inside a loop where the value will not change could be modified to invoke it once, outside the loop.