-
Notifications
You must be signed in to change notification settings - Fork 751
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
Review GroupJoin #648
Review GroupJoin #648
Conversation
var leftSubscription = new SingleAssignmentDisposable(); | ||
_group.Add(leftSubscription); | ||
var leftObserver = new LeftObserver(this); | ||
_group.Add(leftObserver); | ||
_leftID = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason to init to default
var rightSubscription = new SingleAssignmentDisposable(); | ||
_group.Add(rightSubscription); | ||
var rightObserver = new RightObserver(this); | ||
_group.Add(rightObserver); | ||
_rightID = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason to initi to default.
@@ -34,8 +34,8 @@ internal sealed class _ : IdentitySink<TResult> | |||
private readonly object _gate = new object(); | |||
private readonly CompositeDisposable _group = new CompositeDisposable(); | |||
private readonly RefCountDisposable _refCount; | |||
private readonly SortedDictionary<int, IObserver<TRight>> _leftMap = new SortedDictionary<int, IObserver<TRight>>(); | |||
private readonly SortedDictionary<int, TRight> _rightMap = new SortedDictionary<int, TRight>(); | |||
private readonly SortedDictionary<int, IObserver<TRight>> _leftMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How was the original even compiling without an error? You can assign a readonly field twice in C#?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the assignment is done in the constructor, it's valid. And although it's probably never the developer's intention, it doesn't produce a warning. I assume this is due to possible side effects that the initialization could have.
We save some allocations by using the same techniques as in earlier PRs.