From 7e2317b6dc46228d1ecafff67cf2de0e0209e4ef Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Wed, 13 Aug 2008 15:16:42 +0000 Subject: [PATCH] added quick workaround for #1980 (IndexedContainer has sluggish equals/hashCode methods) svn changeset:5181/svn branch:trunk --- src/com/itmill/toolkit/ui/Table.java | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/com/itmill/toolkit/ui/Table.java b/src/com/itmill/toolkit/ui/Table.java index b75bf00413..d5ab6120c3 100644 --- a/src/com/itmill/toolkit/ui/Table.java +++ b/src/com/itmill/toolkit/ui/Table.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.IdentityHashMap; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -43,10 +44,6 @@ import com.itmill.toolkit.terminal.Resource; * @VERSION@ * @since 3.0 */ -/** - * @author mattitahvonen - * - */ public class Table extends AbstractSelect implements Action.Container, Container.Ordered, Container.Sortable { @@ -232,15 +229,18 @@ public class Table extends AbstractSelect implements Action.Container, private Object[][] pageBuffer = null; /** - * List of properties listened - the list is kept to release the listeners + * Set of properties listened - the list is kept to release the listeners * later. + * + * Note: This should be set or list. IdentityHashMap used due very heavy + * hashCode in indexed container */ - private LinkedList listenedProperties = null; + private Map listenedProperties = null; /** - * List of visible components - the is used for needsRepaint calculation. + * Set of visible components - the is used for needsRepaint calculation. */ - private LinkedList visibleComponents = null; + private HashSet visibleComponents = null; /** * List of action handlers. @@ -1166,12 +1166,12 @@ public class Table extends AbstractSelect implements Action.Container, if (isContentRefreshesEnabled) { - LinkedList oldListenedProperties = listenedProperties; - LinkedList oldVisibleComponents = visibleComponents; + Map oldListenedProperties = listenedProperties; + HashSet oldVisibleComponents = visibleComponents; // initialize the listener collections - listenedProperties = new LinkedList(); - visibleComponents = new LinkedList(); + listenedProperties = new IdentityHashMap(); + visibleComponents = new HashSet(); // Collects the basic facts about the table page final Object[] colids = getVisibleColumns(); @@ -1273,11 +1273,12 @@ public class Table extends AbstractSelect implements Action.Container, if (p != null || isGenerated) { if (p instanceof Property.ValueChangeNotifier) { if (oldListenedProperties == null - || !oldListenedProperties.contains(p)) { + || !oldListenedProperties + .containsKey(p)) { ((Property.ValueChangeNotifier) p) .addListener(this); } - listenedProperties.add(p); + listenedProperties.put(p, null); } if (index < firstIndexNotInCache && index >= pageBufferFirstIndex) { @@ -1348,11 +1349,11 @@ public class Table extends AbstractSelect implements Action.Container, } if (oldListenedProperties != null) { - for (final Iterator i = oldListenedProperties.iterator(); i - .hasNext();) { + for (final Iterator i = oldListenedProperties.keySet() + .iterator(); i.hasNext();) { Property.ValueChangeNotifier o = (ValueChangeNotifier) i .next(); - if (!listenedProperties.contains(o)) { + if (!listenedProperties.containsKey(o)) { o.removeListener(this); } } -- 2.39.5