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

chore(refCount): remove unnecessary reference of object #4720

Merged
merged 5 commits into from Jun 22, 2020

Conversation

githubxiaowen
Copy link
Contributor

Description:
Since the source and the connectableObservable is the same thing in RefCountOperator, there is no need to hold the variable connectable int the RefCountOperator
Related issue (if exists):
NONE

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8388

  • 8 of 9 (88.89%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 96.674%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/internal/observable/ConnectableObservable.ts 0 1 0.0%
Totals Coverage Status
Change from base Build 8387: -0.001%
Covered Lines: 5203
Relevant Lines: 5382

💛 - Coveralls

@benlesh
Copy link
Member

benlesh commented May 10, 2019

I'm not sure how I feel about exposing all of these properties as public. They really aren't meant to be consumed by other users.

src/internal/observable/ConnectableObservable.ts Outdated Show resolved Hide resolved
src/internal/operators/refCount.ts Outdated Show resolved Hide resolved
@githubxiaowen githubxiaowen force-pushed the feat-opti-refcount branch 5 times, most recently from 2d70c6c to 02a9eac Compare June 18, 2019 06:54
Copy link
Member

@benlesh benlesh left a comment

Choose a reason for hiding this comment

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

Just a couple of notes that this is a breaking change to to changes in the signature of ConnectableObservable, which is a publicly exposed type.

It's also more of a refactor, as the perf implications aren't proven.

I'd like another opinion from @kwonoj or @cartant

protected _refCount: number = 0;
protected _connection: Subscription;
private _refCount: number = 0;
private _connection: Subscription;
Copy link
Member

Choose a reason for hiding this comment

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

This is technically a breaking change for TypeScript users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, as this would be a breaking change, I don't see any advantage to changing these to private. Especially as this is a 'perf' PR. This is unrelated to perf.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted to protected

} as MonoTypeOperatorFunction<T>;
}

class RefCountOperator<T> implements Operator<T, T> {
constructor(private connectable: ConnectableObservable<T>) {
Copy link
Member

Choose a reason for hiding this comment

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

Removing the constructor is also a breaking change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with this. AFAICT, this is not a breaking change as RefCountOperator is not exported. And if someone has reached into the internals to get it and this breaks them, then that's on them for being naughty.

@benlesh benlesh requested a review from cartant August 1, 2019 20:06
Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

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

I'm fine with this PR. But I don't think the access modifiers should be changed to private.

protected _refCount: number = 0;
protected _connection: Subscription;
private _refCount: number = 0;
private _connection: Subscription;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, as this would be a breaking change, I don't see any advantage to changing these to private. Especially as this is a 'perf' PR. This is unrelated to perf.

} as MonoTypeOperatorFunction<T>;
}

class RefCountOperator<T> implements Operator<T, T> {
constructor(private connectable: ConnectableObservable<T>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with this. AFAICT, this is not a breaking change as RefCountOperator is not exported. And if someone has reached into the internals to get it and this breaks them, then that's on them for being naughty.

revert private to protected
@githubxiaowen
Copy link
Contributor Author

githubxiaowen commented Sep 10, 2019

Yeah,i gave it a second thought. This commit indeed is just removing the unnecessary reference of source, nothing about performance.

@githubxiaowen githubxiaowen changed the title perf(refCount): optimize the implementation of class RefCounterOperator chore(refCount): remove unnecessary reference of object Sep 10, 2019
Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

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

LGTM

This was mostly just to get CI to kick off again.
Again, I was really only doing this to kick off CI. LOL... My silly change in the dark from the GitHub UI didn't work. :)
Really I'm just kicking CI again. (and I made a dumb mistake on the last one)
@benlesh benlesh merged commit 3eacd65 into ReactiveX:master Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants