Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4711

Improve Immutable None Type Instantiation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.12.0
    • 0.13.0
    • Java - Library
    • None
    • Patch

    Description

      Option.java
          public static <T> Option<T> fromNullable(T value) {
              if (value != null) {
                  return new Some<T>(value);
              } else {
                  return new None<T>();
              }
          }
      

      The None class is an immutable object, therefore it does not need to be instantiated for every call to fromNullable. Do the same thing as Java's Collections.emptyList() to allow for a single static instance of None to return.

      https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/Collections.java#L3178-L3180

      Attachments

        Issue Links

          Activity

            People

              jking3 James E. King III
              belugabehr David Mollitor
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m