Skip to content

Commit c3cfb5a

Browse files
authoredNov 1, 2018
2.x: Improve the Observable/Flowable cache() operators (#6275)
* 2.x: Improve the Observable/Flowable cache() operators * Remove unnecessary casting. * Remove another unnecessary cast.
1 parent fba8b61 commit c3cfb5a

File tree

6 files changed

+615
-548
lines changed

6 files changed

+615
-548
lines changed
 

‎src/main/java/io/reactivex/Observable.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -6164,7 +6164,7 @@ public final <B, U extends Collection<? super T>> Observable<U> buffer(Callable<
61646164
@CheckReturnValue
61656165
@SchedulerSupport(SchedulerSupport.NONE)
61666166
public final Observable<T> cache() {
6167-
return ObservableCache.from(this);
6167+
return cacheWithInitialCapacity(16);
61686168
}
61696169

61706170
/**
@@ -6222,7 +6222,8 @@ public final Observable<T> cache() {
62226222
@CheckReturnValue
62236223
@SchedulerSupport(SchedulerSupport.NONE)
62246224
public final Observable<T> cacheWithInitialCapacity(int initialCapacity) {
6225-
return ObservableCache.from(this, initialCapacity);
6225+
ObjectHelper.verifyPositive(initialCapacity, "initialCapacity");
6226+
return RxJavaPlugins.onAssembly(new ObservableCache<T>(this, initialCapacity));
62266227
}
62276228

62286229
/**

0 commit comments

Comments
 (0)