aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Lange <lange.fabian@gmail.com>2014-05-21 14:52:52 +0200
committerVaadin Code Review <review@vaadin.com>2014-05-22 12:11:43 +0000
commitbb650cf78ecbe9d3eeb9cd57a87b042e76bff792 (patch)
treed981fe5d136d8d0c8a8c9386c9eb0a79a62cf7e9
parentbd311030b63d83bc1bab72bcba9fd909652bde19 (diff)
downloadvaadin-framework-bb650cf78ecbe9d3eeb9cd57a87b042e76bff792.tar.gz
vaadin-framework-bb650cf78ecbe9d3eeb9cd57a87b042e76bff792.zip
Optimize getAllChildrenIterable() performance. (#13803)
getAllChildrenIterable() is invoked frequently, its used by attach/detach and markAsDirty. Because of the implementation detail in CombinedIterator, on every call all iterators are checked. This means that on every component which has multiple childs, each next() call will first check the extension iterator, before advancing in the child iterator. By having the childs first, this overhead is reduced. If no extensions are existing (which is quite common) the iterator is not added at all. (creating an iterator on an empty UnmodifiableCollection is waste of time and memory) Change-Id: I23bb91464052ad4282963ec4b5be8a52c6847d4f
-rw-r--r--server/src/com/vaadin/server/AbstractClientConnector.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/server/src/com/vaadin/server/AbstractClientConnector.java b/server/src/com/vaadin/server/AbstractClientConnector.java
index 1e58fb30c0..92c235167c 100644
--- a/server/src/com/vaadin/server/AbstractClientConnector.java
+++ b/server/src/com/vaadin/server/AbstractClientConnector.java
@@ -348,13 +348,16 @@ public abstract class AbstractClientConnector implements ClientConnector,
@Override
public Iterator<ClientConnector> iterator() {
CombinedIterator<ClientConnector> iterator = new CombinedIterator<ClientConnector>();
- iterator.addIterator(connector.getExtensions().iterator());
if (connector instanceof HasComponents) {
HasComponents hasComponents = (HasComponents) connector;
iterator.addIterator(hasComponents.iterator());
}
+ Collection<Extension> extensions = connector.getExtensions();
+ if (extensions.size() > 0) {
+ iterator.addIterator(extensions.iterator());
+ }
return iterator;
}
}