Skip to content

1.x: Optimizate single just #3622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

1.x: Optimizate single just #3622

wants to merge 2 commits into from

Conversation

Chaoba
Copy link

@Chaoba Chaoba commented Jan 18, 2016

This PR add similar optimization as ScalarSynchronousObservable to Single.just method.

@@ -685,6 +679,9 @@ public void call(SingleSubscriber<? super T> te) {
* @see <a href="http://reactivex.io/documentation/operators/merge.html">ReactiveX operators documentation: Merge</a>
*/
public final static <T> Single<T> merge(final Single<? extends Single<? extends T>> source) {
if (source.getClass() == ScalarSynchronousSingle.class) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears instanceof can be optimized much better by JIT than class equivalence checks. Could you rewrite this and all the other places?

@akarnokd akarnokd changed the title Optimizate single just 1.x: Optimizate single just Jan 22, 2016
return new ScalarSynchronousSingle<T>(t);
}

final T t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this to value? Will improve readability of the code!

@artem-zinnatullin
Copy link
Contributor

Nice PR! @Chaoba can you please remove merge commit from the PR (rebase should help)?

@Chaoba Chaoba closed this Jan 25, 2016
@Chaoba Chaoba deleted the optimizate_single_just branch January 25, 2016 02:38
@Chaoba
Copy link
Author

Chaoba commented Jan 25, 2016

@akarnokd and @artem-zinnatullin please review on #3642

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants