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

Review GroupJoin #648

Merged
merged 4 commits into from
Jun 26, 2018
Merged

Review GroupJoin #648

merged 4 commits into from
Jun 26, 2018

Conversation

danielcweber
Copy link
Collaborator

@danielcweber danielcweber commented Jun 25, 2018

We save some allocations by using the same techniques as in earlier PRs.

var leftSubscription = new SingleAssignmentDisposable();
_group.Add(leftSubscription);
var leftObserver = new LeftObserver(this);
_group.Add(leftObserver);
_leftID = 0;
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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#?

Copy link
Collaborator Author

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.

@danielcweber danielcweber merged commit 316efb9 into dotnet:master Jun 26, 2018
@danielcweber danielcweber deleted the ReviewGroupJoin branch June 26, 2018 17:42
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.

2 participants