Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1607

Minor performance enhancement

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.0
    • None
    • java
    • None

    Description

      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;
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            zolyfarkas Zoltan Farkas
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 5m
                5m
                Remaining:
                Remaining Estimate - 5m
                5m
                Logged:
                Time Spent - Not Specified
                Not Specified