diff options
-rw-r--r-- | client/src/com/vaadin/client/ApplicationConnection.java | 33 | ||||
-rw-r--r-- | client/src/com/vaadin/client/metadata/Type.java | 5 | ||||
-rw-r--r-- | client/src/com/vaadin/client/metadata/TypeDataStore.java | 18 |
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) { |