summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2013-08-28 12:34:53 +0300
committerVaadin Code Review <review@vaadin.com>2013-08-28 09:36:54 +0000
commit6dc46c5cfc66defaa7ed2350f20bf2224b419d82 (patch)
tree3fdd76e4febd8b4c652445fe924fa46ecea611a6
parent232eb4238d89fe5d310c343c23ed2424d5ef9822 (diff)
downloadvaadin-framework-6dc46c5cfc66defaa7ed2350f20bf2224b419d82.tar.gz
vaadin-framework-6dc46c5cfc66defaa7ed2350f20bf2224b419d82.zip
Use the add() path of CssLayout only when appending to the end (#11284)
This should get the benefits of the previous optimization on initial rendering without negatively affecting the performance when modifying a layout with complex non-leaf children. Change-Id: Id6fcf3e54469454c6a998a50037c8a93bfb46cf6
-rw-r--r--client/src/com/vaadin/client/ui/VCssLayout.java15
-rw-r--r--client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java8
2 files changed, 15 insertions, 8 deletions
diff --git a/client/src/com/vaadin/client/ui/VCssLayout.java b/client/src/com/vaadin/client/ui/VCssLayout.java
index c073c18ccb..e4fac6acb3 100644
--- a/client/src/com/vaadin/client/ui/VCssLayout.java
+++ b/client/src/com/vaadin/client/ui/VCssLayout.java
@@ -40,20 +40,29 @@ public class VCssLayout extends FlowPanel {
/**
* For internal use only. May be removed or replaced in the future.
- *
- * @deprecated since 7.1.4 no longer used by the framework, might be removed
*/
- @Deprecated
public void addOrMove(Widget child, int index) {
Profiler.enter("VCssLayout.addOrMove");
if (child.getParent() == this) {
+ Profiler.enter("VCssLayout.addOrMove getWidgetIndex");
int currentIndex = getWidgetIndex(child);
+ Profiler.leave("VCssLayout.addOrMove getWidgetIndex");
if (index == currentIndex) {
Profiler.leave("VCssLayout.addOrMove");
return;
}
+ } else if (index == getWidgetCount()) {
+ // optimized path for appending components - faster especially for
+ // initial rendering
+ Profiler.enter("VCssLayout.addOrMove add");
+ add(child);
+ Profiler.leave("VCssLayout.addOrMove add");
+ Profiler.leave("VCssLayout.addOrMove");
+ return;
}
+ Profiler.enter("VCssLayout.addOrMove insert");
insert(child, index);
+ Profiler.leave("VCssLayout.addOrMove insert");
Profiler.leave("VCssLayout.addOrMove");
}
}
diff --git a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
index b6dfffcc55..45e52c890e 100644
--- a/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
+++ b/client/src/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
@@ -123,16 +123,14 @@ public class CssLayoutConnector extends AbstractLayoutConnector {
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
Profiler.enter("CssLayoutConnector.onConnectorHierarchyChange");
Profiler.enter("CssLayoutConnector.onConnectorHierarchyChange add children");
- // for large layouts, significantly faster to clear the list and always
- // append to the end than to move the children around
- getWidget().clear();
+ int index = 0;
for (ComponentConnector child : getChildComponents()) {
VCaption childCaption = childIdToCaption
.get(child.getConnectorId());
if (childCaption != null) {
- getWidget().add(childCaption);
+ getWidget().addOrMove(childCaption, index++);
}
- getWidget().add(child.getWidget());
+ getWidget().addOrMove(child.getWidget(), index++);
}
Profiler.leave("CssLayoutConnector.onConnectorHierarchyChange add children");