Bug 102440 - [Viewers] StructuredViewer.update() loops unnecessarily
Summary: [Viewers] StructuredViewer.update() loops unnecessarily
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on: 89606
Blocks:
  Show dependency tree
 
Reported: 2005-07-01 00:29 EDT by Rutger Ovidius CLA
Modified: 2008-02-05 13:38 EST (History)
1 user (show)

See Also:


Attachments
possible patch against org.eclipse.jface (2.10 KB, patch)
2006-02-13 10:39 EST, Boris Bokowski CLA
no flags Details | Diff
new patch (3.31 KB, patch)
2007-06-21 15:48 EDT, Boris Bokowski CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rutger Ovidius CLA 2005-07-01 00:29:22 EDT
StructuredViewer.java:

public void update(Object[] elements, String[] properties) {
		for (int i = 0; i < elements.length; ++i)
			update(elements[i], properties);
}
This loops through all the elements fed to it, which calls 

update(Object element, String[] properties) 

which calls

internalUpdate(Widget widget, Object element, String[] properties)

which checks the properties with the filter&sorter:

if (needsRefilter) {
  refresh();
  return;
}

And if successful a full refresh has been done, yet update() is still looping 
over more elements to update.  The full refresh gets/filters/sorts _all_ the 
elements as far as I understand it.  There is no need to continue.

Updating with an Object[] of 1000 elements that triggers the refresh() on the 
first element need not call update() on the remaining 999 elements.  They could 
theoretically be 999 elements that trigger a refresh() (resulting in a bogged 
down gui thread..)
Comment 1 Boris Bokowski CLA 2005-11-09 17:02:37 EST
It will be easier to fix this one once we made StructuralViewer.internalUpdate
private again.
Comment 2 Boris Bokowski CLA 2005-11-09 17:03:22 EST
Therefore, I have added a dependency on bug 89606.
Comment 3 Boris Bokowski CLA 2006-02-13 10:39:41 EST
Created attachment 34572 [details]
possible patch against org.eclipse.jface

Since we haven't been able to make internalUpdate private again, I don't think I can release the fix for this yet.
Comment 4 Boris Bokowski CLA 2006-02-13 10:45:16 EST
Moving to 3.2M6. I'll try my best to convince JDT to not use internalUpdate anymore, which would allow fixing this.
Comment 5 Boris Bokowski CLA 2006-04-12 14:26:38 EDT
Sorry, bug I didn't have the time for lobbying. Deferring to 3.3.
Comment 6 Boris Bokowski CLA 2007-04-27 20:55:22 EDT
Deferring again.  Workaround is to pass null for the properties array, which avoids the inner loop if you don't need a refresh, or calling refresh directly if you need it.
Comment 7 Boris Bokowski CLA 2007-06-21 15:48:09 EDT
Created attachment 72079 [details]
new patch
Comment 8 Boris Bokowski CLA 2007-06-21 15:51:41 EDT
Michael, this patch will likely break CommonViewer because it relies on an unspecified implementation detail: StructuredViewer.update(Object[], String[]) currently calls update(Object, String[]) but after applying this patch, it won't do that anymore.

Would it be possible that you override update(Object[], String[]) as well?
Comment 9 Boris Bokowski CLA 2007-09-18 13:19:29 EDT
Moving to M3.
Comment 10 Boris Bokowski CLA 2007-10-29 00:53:45 EDT
Michael, could you please have a look at this and comment?  I would be interested in your opinion as to how likely it is that someone else (the original WTP common navigator?) made the assumption that StructuredViewer.update(Object[], String[]) calls update(Object, String[]).
Comment 11 Michael D. Elder CLA 2007-10-29 08:59:18 EDT
So far as I'm aware, most of the implementations of content extensions from WTP land make use of update(obj, null); I'm not aware of any implementation that makes use of the string array for properties. 

Until 3.3, the CNF actually called refresh() as a result of it's update(obj, ..) method because of deficiencies with known notification patterns from existent content providers. 

Comment 12 Boris Bokowski CLA 2008-02-03 17:28:36 EST
Fixed in HEAD > 20080203. I made no assumptions about who calls what in my fix. It is really ugly because of that but should work.

Rutger, would you be able to confirm that this fixes the problem you reported? Thanks
Comment 13 Boris Bokowski CLA 2008-02-05 13:38:50 EST
Rutger, I would appreciate if you could download a recent integration build (for example, I20080205-0010) and confirm that the fix solves the reported problem.