Handle DynamicAttributeProvider with a lower priority than Maps and Arrays, see
Motivation:
introduced `DynamicAttributeProvider`. Type checking in
`GetAttributeExpression` seems to be pretty expensive, so as
`DynamicAttributeProvider` is not commonly used, Maps and Arrays
branches should have higher priority.
Modification:
Move the `DynamicAttributeProvider` branch down.
Result:
+10% throughput
@@ -90,14 +90,6 @@ public class GetAttributeExpression implements Expression<Object> {
Object[] argumentValues = this.getArgumentValues(self, context);
- // check if the object is able to provide the attribute dynamically
- if(object != null && object instanceof DynamicAttributeProvider) {
- DynamicAttributeProvider dynamicAttributeProvider = (DynamicAttributeProvider) object;
- if(dynamicAttributeProvider.canProvideDynamicAttribute(attributeName)) {
- return dynamicAttributeProvider.getDynamicAttribute(attributeNameValue, argumentValues);
- }
- }
-
Member member = object == null ? null : this.memberCache.get(new MemberCacheKey(object.getClass(), attributeName));
if (object != null && member == null) {
@@ -157,6 +149,14 @@ public class GetAttributeExpression implements Expression<Object> {
}
+ // check if the object is able to provide the attribute dynamically
+ if(object instanceof DynamicAttributeProvider) {
+ DynamicAttributeProvider dynamicAttributeProvider = (DynamicAttributeProvider) object;
+ if(dynamicAttributeProvider.canProvideDynamicAttribute(attributeName)) {
+ return dynamicAttributeProvider.getDynamicAttribute(attributeNameValue, argumentValues);
+ }
+ }
+
/*
* turn args into an array of types and an array of values in order
* to use them for our reflection calls
