Skip to content

Commit

Permalink
2.x: Improve the Observable/Flowable cache() operators (#6275)
Browse files Browse the repository at this point in the history
* 2.x: Improve the Observable/Flowable cache() operators

* Remove unnecessary casting.

* Remove another unnecessary cast.
  • Loading branch information
akarnokd authored Nov 1, 2018
1 parent fba8b61 commit c3cfb5a
Show file tree
Hide file tree
Showing 6 changed files with 615 additions and 548 deletions.
5 changes: 3 additions & 2 deletions src/main/java/io/reactivex/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -6164,7 +6164,7 @@ public final <B, U extends Collection<? super T>> Observable<U> buffer(Callable<
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Observable<T> cache() {
return ObservableCache.from(this);
return cacheWithInitialCapacity(16);
}

/**
Expand Down Expand Up @@ -6222,7 +6222,8 @@ public final Observable<T> cache() {
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final Observable<T> cacheWithInitialCapacity(int initialCapacity) {
return ObservableCache.from(this, initialCapacity);
ObjectHelper.verifyPositive(initialCapacity, "initialCapacity");
return RxJavaPlugins.onAssembly(new ObservableCache<T>(this, initialCapacity));
}

/**
Expand Down
Loading

0 comments on commit c3cfb5a

Please sign in to comment.