]> source.dussan.org Git - vaadin-framework.git/commitdiff
Improve performance of setNeedsMeasure (#16972).
authorFabian Lange <lange.fabian@gmail.com>
Mon, 2 Mar 2015 12:08:02 +0000 (13:08 +0100)
committerFabian Lange <lange.fabian@gmail.com>
Wed, 11 Mar 2015 08:57:21 +0000 (09:57 +0100)
This change removes the method LayoutDependenyTree.setNeedsMeasure which
takes a connectorId as first param.
In all places where it is used, the ComponentConnector is actually known,
so this change avoids looking it up over and over again.
Also The lookup would need to lookup the ConnectorMap every time.

Change-Id: I2593b0bede05cd69889ba68aac854cfba43f70b1

client/src/com/vaadin/client/LayoutManager.java
client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java

index dfcf2cb5bb2f2abbfdddfb5f798fc33e75be77e4..828f0942b7718620ece234c038bb99908c1cd49c 100644 (file)
@@ -310,8 +310,11 @@ public class LayoutManager {
         dump = needsMeasure.dump();
         dumpLength = dump.length();
         for (int i = 0; i < dumpLength; i++) {
-            String layoutId = dump.get(i);
-            currentDependencyTree.setNeedsMeasure(layoutId, true);
+            ServerConnector connector = connectorMap.getConnector(dump.get(i));
+            if (connector != null) {
+                currentDependencyTree.setNeedsMeasure(
+                        (ComponentConnector) connector, true);
+            }
         }
         needsMeasure = FastStringSet.create();
 
@@ -661,7 +664,7 @@ public class LayoutManager {
                 parentElement.getStyle().setProperty("overflow",
                         originalOverflows.get(parentElement));
 
-                layoutDependencyTree.setNeedsMeasure(connectorId, true);
+                layoutDependencyTree.setNeedsMeasure(componentConnector, true);
             }
             Profiler.leave("Overflow fix restore");
 
@@ -695,8 +698,7 @@ public class LayoutManager {
                 measureConnector(connectors.get(i));
             }
             for (int i = 0; i < connectorCount; i++) {
-                layoutDependencyTree.setNeedsMeasure(connectors.get(i)
-                        .getConnectorId(), false);
+                layoutDependencyTree.setNeedsMeasure(connectors.get(i), false);
             }
             measureCount += connectorCount;
 
@@ -715,8 +717,9 @@ public class LayoutManager {
                 measureCount++;
             }
             for (int i = 0; i < length; i++) {
-                String connectorId = measureTargets.get(i);
-                layoutDependencyTree.setNeedsMeasure(connectorId, false);
+                ComponentConnector connector = (ComponentConnector) connectorMap
+                        .getConnector(measureTargets.get(i));
+                layoutDependencyTree.setNeedsMeasure(connector, false);
             }
         }
         Profiler.leave("Layout measure from tree");
index af261c020820a43b70b5a0cb8056909d240f9eb0..07bb6688e3c01969d8de4184a4a3fcf14f626287 100644 (file)
@@ -429,6 +429,15 @@ public class LayoutDependencyTree {
         setNeedsVerticalMeasure(connector, needsMeasure);
     }
 
+    /**
+     * @param connectorId
+     * @param needsMeasure
+     * 
+     * @deprecated As of 7.4.2, use
+     *             {@link #setNeedsMeasure(ComponentConnector, boolean)} for
+     *             improved performance.
+     */
+    @Deprecated
     public void setNeedsMeasure(String connectorId, boolean needsMeasure) {
         ComponentConnector connector = (ComponentConnector) ConnectorMap.get(
                 connection).getConnector(connectorId);