Skip to content
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

perf(internal): optimize Subscription#add() for the common case #4489

Merged
merged 1 commit into from
Jan 24, 2019

Conversation

bmeurer
Copy link
Contributor

@bmeurer bmeurer commented Jan 24, 2019

This removes unnecessary checks on the teardown parameter upfront, and
instead moves these checks into the appropriate branches guarded by the
type check. This way we get the same behavior, but with fewer checks and
smaller code size.

Also optimize adding the child subscription to this._subscriptions
for the common case that there were no previous subscriptions.

This removes unnecessary checks on the `teardown` parameter upfront, and
instead moves these checks into the appropriate branches guarded by the
type check. This way we get the same behavior, but with fewer checks and
smaller code size.

Also optimize adding the child `subscription` to `this._subscriptions`
for the common case that there were no previous subscriptions.
@@ -168,13 +160,21 @@ export class Subscription implements SubscriptionLike {
subscription._subscriptions = [tmp];
}
break;
default:
default: {
if (!(<any>teardown)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this just leftover defensive programming? Or is this on purpose?

Copy link
Member

Choose a reason for hiding this comment

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

Seems like it's leftover.

@coveralls
Copy link

coveralls commented Jan 24, 2019

Pull Request Test Coverage Report for Build 7942

  • 9 of 9 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 96.813%

Files with Coverage Reduction New Missed Lines %
src/internal/Subscription.ts 1 91.95%
Totals Coverage Status
Change from base Build 7939: -0.2%
Covered Lines: 5256
Relevant Lines: 5429

💛 - Coveralls

@benlesh benlesh merged commit bdd201c into ReactiveX:master Jan 24, 2019
@bmeurer bmeurer deleted the Subscription_add_common branch January 25, 2019 10:59
@lock lock bot locked as resolved and limited conversation to collaborators Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants