Skip to content

Commit

Permalink
Merge pull request #1951 from abersnaze/unnecessary
Browse files Browse the repository at this point in the history
Remove extraneous request(n) and onCompleted() calls when unsubscribed.
  • Loading branch information
benjchristensen committed Dec 12, 2014
2 parents f934706 + 332b67c commit 1b39e6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ public void request(long n) {
}

if (!it.hasNext()) {
o.onCompleted();
if (!o.isUnsubscribed()) {
o.onCompleted();
}
return;
}
if (REQUESTED_UPDATER.addAndGet(this, -r) == 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/rx/internal/operators/OperatorMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ private void handleNewSource(Observable<? extends T> t) {
InnerSubscriber<T> i = new InnerSubscriber<T>(this, producerIfNeeded);
i.sindex = childrenSubscribers.add(i);
t.unsafeSubscribe(i);
request(1);
if (!isUnsubscribed())
request(1);
}

private void handleScalarSynchronousObservable(ScalarSynchronousObservable<? extends T> t) {
Expand Down

0 comments on commit 1b39e6b

Please sign in to comment.