[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avro-dev
Subject:    [jira] [Created] (AVRO-1607) Minor performance enhancement
From:       "Zoltan Farkas (JIRA)" <jira () apache ! org>
Date:       2014-11-18 16:22:34
Message-ID: JIRA.12756139.1416327749000.525561.1416327754225 () Atlassian ! JIRA
[Download RAW message or body]

Zoltan Farkas created AVRO-1607:
-----------------------------------

             Summary: 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


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)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic