Skip to content

Conversation

@rozele
Copy link
Contributor

@rozele rozele commented Mar 3, 2018

The recent work to avoid reflection for native modules can also be applied to native props for view managers (which also uses reflection). Avoiding reflection invoke saves quite a few cycles.

This change extracts the logic from ReflectionReactDelegateFactory to create the IGenericDelegate, and adds support for generic delegates where the instance isn't known up-front. We need this because the ViewManager responsible for creating all the PropertySetters only holds a reference to the ShadowNode type, not the ShadowNode instance itself.

The recent work to avoid reflection for native modules can also be applied to native props for view managers (which also uses reflection). Avoiding reflection invoke saves quite a few cycles.

This change extracts the logic from ReflectionReactDelegateFactory to create the IGenericDelegate, and adds support for generic delegates where the instance isn't known up-front. We need this because the ViewManager responsible for creating all the PropertySetters only holds a reference to the ShadowNode type, not the ShadowNode instance itself.
@rozele
Copy link
Contributor Author

rozele commented Mar 3, 2018

cc @matthargett

Reflection invoke automatically converts null arguments to default struct values. We have to do something similar here when we avoid reflection invoke.
@rozele rozele merged commit 614057f into microsoft:master Mar 6, 2018
@rozele rozele deleted the noReflectionInvokeProps branch March 6, 2018 14:00
ladipro pushed a commit to ladipro/react-native-windows that referenced this pull request May 16, 2018
…microsoft#1691)

The recent work to avoid reflection for native modules can also be applied to native props for view managers (which also uses reflection). Avoiding reflection invoke saves quite a few cycles.

This change extracts the logic from ReflectionReactDelegateFactory to create the IGenericDelegate, and adds support for generic delegates where the instance isn't known up-front. We need this because the ViewManager responsible for creating all the PropertySetters only holds a reference to the ShadowNode type, not the ShadowNode instance itself.

Also includes fix for reflection invoke behavior when dealing with null value types. Reflection invoke automatically converts null arguments to default value type (i.e., struct) values. We have to do something similar here when we invoke through generic delegates.

(cherry picked from commit 614057f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants