Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Remove version increment from Dictionary<K,V>.Remove overloads #18854

Merged
merged 5 commits into from
Jul 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,6 @@ public bool Remove(TKey key)
}
_freeList = i;
_freeCount++;
_version++;
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth a comment indicating why we aren't incrementing version in these places - without context, it might look like a mistake.

Copy link
Member

Choose a reason for hiding this comment

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

As an aside I think we are inconsistent already. Looks like both TrimExcess() and EnsureCapacity() are missing version increments, even though they can invalidate an enumeration.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like both TrimExcess() and EnsureCapacity() are missing version increments, even though they can invalidate an enumeration.

Bug that we should fix?

Copy link
Author

Choose a reason for hiding this comment

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

Both could silently change enumeration results in the worst case so i'd say bug and fix.

Copy link
Member

Choose a reason for hiding this comment

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

return true;
}

Expand Down Expand Up @@ -865,7 +864,6 @@ public bool Remove(TKey key, out TValue value)
}
_freeList = i;
_freeCount++;
_version++;
return true;
}

Expand Down