Skip to content

Commit 0db09c3

Browse files
Remove Subscription Wrapper from Observable.subscribe
Performance increase from 7.7m to 8.8m ops/second Before: Benchmark (size) Mode Samples Mean Mean error Units r.u.PerfTransforms.mapTransformation 1 thrpt 5 7714453.187 362218.633 ops/s r.u.PerfTransforms.mapTransformation 1 thrpt 5 7527144.767 497816.471 ops/s After: Benchmark (size) Mode Samples Mean Mean error Units r.u.PerfTransforms.mapTransformation 1 thrpt 5 8853534.333 183494.242 ops/s r.u.PerfTransforms.mapTransformation 1 thrpt 5 8806958.403 452595.219 ops/s
1 parent 310ceca commit 0db09c3

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6255,16 +6255,7 @@ public final Subscription subscribe(Subscriber<? super T> subscriber) {
62556255
subscriber = new SafeSubscriber<T>(subscriber);
62566256
}
62576257
onSubscribeFunction.call(subscriber);
6258-
final Subscription returnSubscription = hook.onSubscribeReturn(subscriber);
6259-
// we return it inside a Subscription so it can't be cast back to Subscriber
6260-
return Subscriptions.create(new Action0() {
6261-
6262-
@Override
6263-
public void call() {
6264-
returnSubscription.unsubscribe();
6265-
}
6266-
6267-
});
6258+
return hook.onSubscribeReturn(subscriber);
62686259
} catch (Throwable e) {
62696260
// special handling for certain Throwable/Error/Exception types
62706261
Exceptions.throwIfFatal(e);

0 commit comments

Comments
 (0)