summaryrefslogtreecommitdiffstats
path: root/client/src/com
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-02-20 15:40:36 +0200
committerVaadin Code Review <review@vaadin.com>2013-02-25 14:36:20 +0000
commitb89719f3856be6bad0c04c40db46965083db8ef4 (patch)
treef344a2ade2e0fe1ed7e0ba071a640f44785ec686 /client/src/com
parent9a59383cd7a0a87c76eeed38a18273f661d95b1b (diff)
downloadvaadin-framework-b89719f3856be6bad0c04c40db46965083db8ef4.tar.gz
vaadin-framework-b89719f3856be6bad0c04c40db46965083db8ef4.zip
Do @DelegateToWidget based on applicable properties (#10954)
This change improves performance by itself and is needed for avoiding the dependency on StateChangeEvent.getChangedProperties() Change-Id: I590bc98e12bbb4ecaaa972b5f49c62dea91ac06c
Diffstat (limited to 'client/src/com')
-rw-r--r--client/src/com/vaadin/client/ApplicationConnection.java33
-rw-r--r--client/src/com/vaadin/client/metadata/Type.java5
-rw-r--r--client/src/com/vaadin/client/metadata/TypeDataStore.java18
3 files changed, 44 insertions, 12 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java
index 729a68df3c..e669b3ae96 100644
--- a/client/src/com/vaadin/client/ApplicationConnection.java
+++ b/client/src/com/vaadin/client/ApplicationConnection.java
@@ -1605,24 +1605,37 @@ public class ApplicationConnection {
VConsole.log(" * Running @DelegateToWidget");
+ // Keep track of types that have no @DelegateToWidget in their
+ // state to optimize performance
+ FastStringSet noOpTypes = FastStringSet.create();
+
for (StateChangeEvent sce : pendingStateChangeEvents) {
ServerConnector connector = sce.getConnector();
if (connector instanceof ComponentConnector) {
+ String className = connector.getClass().getName();
+ if (noOpTypes.contains(className)) {
+ continue;
+ }
ComponentConnector component = (ComponentConnector) connector;
Type stateType = AbstractConnector
.getStateType(component);
+ JsArrayString delegateToWidgetProperties = stateType
+ .getDelegateToWidgetProperties();
+ if (delegateToWidgetProperties == null) {
+ noOpTypes.add(className);
+ continue;
+ }
- FastStringSet changedProperties = sce
- .getChangedPropertiesFastSet();
- JsArrayString dump = changedProperties.dump();
- for (int i = 0; i < dump.length(); i++) {
- String propertyName = dump.get(i);
- Property property = stateType
- .getProperty(propertyName);
- String method = property
- .getDelegateToWidgetMethodName();
- if (method != null) {
+ int length = delegateToWidgetProperties.length();
+ for (int i = 0; i < length; i++) {
+ String propertyName = delegateToWidgetProperties
+ .get(i);
+ if (sce.hasPropertyChanged(propertyName)) {
+ Property property = stateType
+ .getProperty(propertyName);
+ String method = property
+ .getDelegateToWidgetMethodName();
Profiler.enter("doDelegateToWidget");
doDelegateToWidget(component, property, method);
Profiler.leave("doDelegateToWidget");
diff --git a/client/src/com/vaadin/client/metadata/Type.java b/client/src/com/vaadin/client/metadata/Type.java
index 9c8a52d8e5..c09dffa638 100644
--- a/client/src/com/vaadin/client/metadata/Type.java
+++ b/client/src/com/vaadin/client/metadata/Type.java
@@ -17,6 +17,7 @@ package com.vaadin.client.metadata;
import java.util.Collection;
+import com.google.gwt.core.client.JsArrayString;
import com.vaadin.client.JsArrayObject;
import com.vaadin.client.communication.JSONSerializer;
@@ -138,4 +139,8 @@ public class Type {
return TypeDataStore.hasProperties(this);
}
+ public JsArrayString getDelegateToWidgetProperties() {
+ return TypeDataStore.getDelegateToWidgetProperites(this);
+ }
+
}
diff --git a/client/src/com/vaadin/client/metadata/TypeDataStore.java b/client/src/com/vaadin/client/metadata/TypeDataStore.java
index c1eca0a168..dff02749f8 100644
--- a/client/src/com/vaadin/client/metadata/TypeDataStore.java
+++ b/client/src/com/vaadin/client/metadata/TypeDataStore.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.Collection;
import com.google.gwt.core.client.JavaScriptObject;
+import com.google.gwt.core.client.JsArrayString;
import com.vaadin.client.FastStringMap;
import com.vaadin.client.FastStringSet;
import com.vaadin.client.JsArrayObject;
@@ -35,6 +36,8 @@ public class TypeDataStore {
.create();
private final FastStringMap<JsArrayObject<Property>> properties = FastStringMap
.create();
+ private final FastStringMap<JsArrayString> delegateToWidgetProperties = FastStringMap
+ .create();
private final FastStringSet delayedMethods = FastStringSet.create();
private final FastStringSet lastOnlyMethods = FastStringSet.create();
@@ -118,11 +121,22 @@ public class TypeDataStore {
return get().delegateToWidget.get(property.getSignature());
}
+ public static JsArrayString getDelegateToWidgetProperites(Type type) {
+ return get().delegateToWidgetProperties.get(type.getSignature());
+ }
+
public void setDelegateToWidget(Class<?> clazz, String propertyName,
String delegateValue) {
- delegateToWidget.put(
- new Property(getType(clazz), propertyName).getSignature(),
+ Type type = getType(clazz);
+ delegateToWidget.put(new Property(type, propertyName).getSignature(),
delegateValue);
+ JsArrayString typeProperties = delegateToWidgetProperties.get(type
+ .getSignature());
+ if (typeProperties == null) {
+ typeProperties = JavaScriptObject.createArray().cast();
+ delegateToWidgetProperties.put(type.getSignature(), typeProperties);
+ }
+ typeProperties.push(propertyName);
}
public void setReturnType(Class<?> type, String methodName, Type returnType) {