@@ -2295,7 +2295,7 @@ public final Observable<Observable<T>> nest() {
22952295 * @see <a href="http://reactivex.io/documentation/operators/empty-never-throw.html">ReactiveX operators documentation: Never</a>
22962296 */
22972297 public final static <T > Observable <T > never () {
2298- return new NeverObservable < T > ();
2298+ return NeverObservable . instance ();
22992299 }
23002300
23012301 /**
@@ -4026,7 +4026,7 @@ public final <T2> Observable<T2> dematerialize() {
40264026 * @see <a href="http://reactivex.io/documentation/operators/distinct.html">ReactiveX operators documentation: Distinct</a>
40274027 */
40284028 public final Observable <T > distinct () {
4029- return lift (new OperatorDistinct < T , T >( UtilityFunctions .<T >identity () ));
4029+ return lift (OperatorDistinct .<T > instance ( ));
40304030 }
40314031
40324032 /**
@@ -4064,7 +4064,7 @@ public final <U> Observable<T> distinct(Func1<? super T, ? extends U> keySelecto
40644064 * @see <a href="http://reactivex.io/documentation/operators/distinct.html">ReactiveX operators documentation: Distinct</a>
40654065 */
40664066 public final Observable <T > distinctUntilChanged () {
4067- return lift (new OperatorDistinctUntilChanged < T , T >( UtilityFunctions .<T >identity () ));
4067+ return lift (OperatorDistinctUntilChanged .<T > instance ( ));
40684068 }
40694069
40704070 /**
@@ -4959,8 +4959,13 @@ public final Observable<T> ignoreElements() {
49594959 * @return an Observable that emits a Boolean
49604960 * @see <a href="http://reactivex.io/documentation/operators/contains.html">ReactiveX operators documentation: Contains</a>
49614961 */
4962+ @ SuppressWarnings ("unchecked" )
49624963 public final Observable <Boolean > isEmpty () {
4963- return lift (new OperatorAny <T >(UtilityFunctions .alwaysTrue (), true ));
4964+ return lift ((OperatorAny <T >) HolderAnyForEmpty .INSTANCE );
4965+ }
4966+
4967+ private static class HolderAnyForEmpty {
4968+ static final OperatorAny <?> INSTANCE = new OperatorAny <Object >(UtilityFunctions .alwaysTrue (), true );
49644969 }
49654970
49664971 /**
@@ -5226,7 +5231,7 @@ public final Boolean call(T t) {
52265231 * @see <a href="http://reactivex.io/documentation/operators/backpressure.html">ReactiveX operators documentation: backpressure operators</a>
52275232 */
52285233 public final Observable <T > onBackpressureBuffer () {
5229- return lift (new OperatorOnBackpressureBuffer <T >());
5234+ return lift (OperatorOnBackpressureBuffer . <T > instance ());
52305235 }
52315236
52325237 /**
@@ -6709,7 +6714,7 @@ public final Observable<T> share() {
67096714 * @see <a href="http://reactivex.io/documentation/operators/first.html">ReactiveX operators documentation: First</a>
67106715 */
67116716 public final Observable <T > single () {
6712- return lift (new OperatorSingle <T >());
6717+ return lift (OperatorSingle . <T > instance ());
67136718 }
67146719
67156720 /**
@@ -9276,7 +9281,22 @@ public final <T2, R> Observable<R> zipWith(Observable<? extends T2> other, Func2
92769281 * the type of item (not) emitted by the Observable
92779282 */
92789283 private static class NeverObservable <T > extends Observable <T > {
9279- public NeverObservable () {
9284+
9285+ private static class Holder {
9286+ static final NeverObservable <?> INSTANCE = new NeverObservable <Object >();
9287+ }
9288+
9289+ /**
9290+ * Returns a singleton instance of NeverObservble (cast to the generic type).
9291+ *
9292+ * @return
9293+ */
9294+ @ SuppressWarnings ("unchecked" )
9295+ static <T > NeverObservable <T > instance () {
9296+ return (NeverObservable <T >) Holder .INSTANCE ;
9297+ }
9298+
9299+ NeverObservable () {
92809300 super (new OnSubscribe <T >() {
92819301
92829302 @ Override
0 commit comments