Skip to content

Conversation

@danielcweber
Copy link
Collaborator

@danielcweber danielcweber commented Jun 25, 2018

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

_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

_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.

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