Skip to content

Commit

Permalink
Remove Subscription Wrapper from Observable.subscribe
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benjchristensen committed May 22, 2014
1 parent 310ceca commit 0db09c3
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions rxjava-core/src/main/java/rx/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -6255,16 +6255,7 @@ public final Subscription subscribe(Subscriber<? super T> subscriber) {
subscriber = new SafeSubscriber<T>(subscriber);
}
onSubscribeFunction.call(subscriber);
final Subscription returnSubscription = hook.onSubscribeReturn(subscriber);
// we return it inside a Subscription so it can't be cast back to Subscriber
return Subscriptions.create(new Action0() {

@Override
public void call() {
returnSubscription.unsubscribe();
}

});
return hook.onSubscribeReturn(subscriber);
} catch (Throwable e) {
// special handling for certain Throwable/Error/Exception types
Exceptions.throwIfFatal(e);
Expand Down

0 comments on commit 0db09c3

Please sign in to comment.