BELUGA BEHR created THRIFT-4711:
-----------------------------------
Summary: Improve Immutable None Type Instantiation
Key: THRIFT-4711
URL: https://issues.apache.org/jira/browse/THRIFT-4711
Project: Thrift
Issue Type: Improvement
Components: Java - Library
Affects Versions: 0.12.0
Reporter: BELUGA BEHR
{code:title=Option.java}
public static <T> Option<T> fromNullable(T value) {
if (value != null) {
return new Some<T>(value);
} else {
return new None<T>();
}
}
{code}
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
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)