From: Fabian Lange Date: Mon, 2 Mar 2015 12:08:02 +0000 (+0100) Subject: Improve performance of setNeedsMeasure (#16972). X-Git-Tag: 7.5.0.alpha1~29 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed8ac01fbd34d4ef8654bc458b83773898aa55b4;p=vaadin-framework.git Improve performance of setNeedsMeasure (#16972). 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 --- diff --git a/client/src/com/vaadin/client/LayoutManager.java b/client/src/com/vaadin/client/LayoutManager.java index dfcf2cb5bb..828f0942b7 100644 --- a/client/src/com/vaadin/client/LayoutManager.java +++ b/client/src/com/vaadin/client/LayoutManager.java @@ -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"); diff --git a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java index af261c0208..07bb6688e3 100644 --- a/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java +++ b/client/src/com/vaadin/client/ui/layout/LayoutDependencyTree.java @@ -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);