[
https://issues.apache.org/jira/browse/AVRO-1607?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14248685#comment-14248685
]
Doug Cutting commented on AVRO-1607:
------------------------------------
Can you please create a benchmark that shows this optimization is significant?
Ideally this would be added to Perf.java.
> Minor performance enhancement
> -----------------------------
>
> Key: AVRO-1607
> URL: https://issues.apache.org/jira/browse/AVRO-1607
> Project: Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.8.0
> Reporter: Zoltan Farkas
> Priority: Minor
> Original Estimate: 5m
> Remaining Estimate: 5m
>
> In SpecificData.getClass, line 164:
> case UNION:
> List<Schema> types = schema.getTypes(); // elide unions with null
> if ((types.size() == 2) && types.contains(NULL_SCHEMA))
> return getWrapper(types.get(types.get(0).equals(NULL_SCHEMA) ? 1 :
> 0));
> return Object.class;
> can be written more efficiently as:
> case UNION:
> List<Schema> types = schema.getTypes(); // elide unions with null
> if ((types.size() == 2)) {
> if (NULL_SCHEMA.equals(types.get(0))) {
> return getWrapper(types.get(1));
> } else if (NULL_SCHEMA.equals(types.get(1))) {
> return getWrapper(types.get(0));
> }
> }
> return Object.class;
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)