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

Commit

Permalink
Revert behaviour change version moves
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams committed Mar 25, 2018
1 parent c5bb5ba commit 3971a59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/mscorlib/shared/System/Collections/Generic/Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ public bool Remove(TKey key)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
}

_version++;
if (_buckets != null)
{
int hashCode = (_comparer?.GetHashCode(key) ?? key.GetHashCode()) & 0x7FFFFFFF;
Expand Down Expand Up @@ -708,6 +707,7 @@ public bool Remove(TKey key)
}
_freeList = i;
_freeCount++;
_version++;
return true;
}

Expand All @@ -728,7 +728,6 @@ public bool Remove(TKey key, out TValue value)
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
}

_version++;
if (_buckets != null)
{
int hashCode = (_comparer?.GetHashCode(key) ?? key.GetHashCode()) & 0x7FFFFFFF;
Expand Down Expand Up @@ -767,6 +766,7 @@ public bool Remove(TKey key, out TValue value)
}
_freeList = i;
_freeCount++;
_version++;
return true;
}

Expand Down
9 changes: 5 additions & 4 deletions src/mscorlib/shared/System/Collections/Generic/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ public int IndexOf(T item, int index, int count)
//
public void Insert(int index, T item)
{
_version++;
// Note that insertions at the end are legal.
if ((uint)index > (uint)_size)
{
Expand All @@ -689,6 +688,7 @@ public void Insert(int index, T item)
}
_items[index] = item;
_size++;
_version++;
}

void IList.Insert(int index, object item)
Expand Down Expand Up @@ -868,7 +868,6 @@ void IList.Remove(object item)
// The complexity is O(n).
public int RemoveAll(Predicate<T> match)
{
_version++;
if (match == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
Expand Down Expand Up @@ -900,6 +899,7 @@ public int RemoveAll(Predicate<T> match)

int result = _size - freeIndex;
_size = freeIndex;
_version++;
return result;
}

Expand Down Expand Up @@ -947,12 +947,13 @@ public void RemoveRange(int index, int count)
{
Array.Copy(_items, index + count, _items, index, _size - index);
}

_version++;
if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
{
Array.Clear(_items, _size, count);
}
}
_version++;
}

// Reverses the elements in this list.
Expand Down Expand Up @@ -1091,10 +1092,10 @@ public bool TrueForAll(Predicate<T> match)

private void AddEnumerable(IEnumerable<T> enumerable)
{
_version++; // Even if the enumerable has no items, we can update _version.
Debug.Assert(enumerable != null);
Debug.Assert(!(enumerable is ICollection<T>), "We should have optimized for this beforehand.");

_version++; // Even if the enumerable has no items, we can update _version.
using (IEnumerator<T> en = enumerable.GetEnumerator())
{

Expand Down

0 comments on commit 3971a59

Please sign in to comment.