summaryrefslogtreecommitdiff
path: root/src/mscorlib
diff options
context:
space:
mode:
authorJames Ko <jamesqko@gmail.com>2016-11-27 12:35:55 -0500
committerJames Ko <jamesqko@gmail.com>2016-11-27 12:35:55 -0500
commita2a8951f38b264e48653a1d77d81b8d77bf59d76 (patch)
tree792ef3067cc5ed607a21d6ebc42176dfcc6a26c6 /src/mscorlib
parent8f696732033b58a0cad119624535854c2dd48dff (diff)
downloadcoreclr-a2a8951f38b264e48653a1d77d81b8d77bf59d76.tar.gz
coreclr-a2a8951f38b264e48653a1d77d81b8d77bf59d76.tar.bz2
coreclr-a2a8951f38b264e48653a1d77d81b8d77bf59d76.zip
Revert some potentially breaking aspects
Diffstat (limited to 'src/mscorlib')
-rw-r--r--src/mscorlib/src/System/Collections/Generic/List.cs31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/mscorlib/src/System/Collections/Generic/List.cs b/src/mscorlib/src/System/Collections/Generic/List.cs
index f12d99202e..0241934a17 100644
--- a/src/mscorlib/src/System/Collections/Generic/List.cs
+++ b/src/mscorlib/src/System/Collections/Generic/List.cs
@@ -1036,32 +1036,19 @@ namespace System.Collections.Generic {
using (IEnumerator<T> en = enumerable.GetEnumerator())
{
T[] items = _items;
- int size = _size;
- // Read in items from the enumerator, only updating fields
- // when we run out of space.
-
- try
+ while (en.MoveNext())
{
- while (en.MoveNext())
+ if (_size == items.Length)
{
- if (size == items.Length)
- {
- _size = size;
- EnsureCapacity(size + 1);
- items = _items;
- }
-
- // Note: It's important we increment size after Current is called.
- // If that throws an exception we don't want to do the increment.
- items[size] = en.Current;
- size++;
+ EnsureCapacity(_size + 1);
+ items = _items;
}
- }
- finally
- {
- // Make a final update to _size and _version after we've finished adding.
- _size = size;
+
+ // Note: It's important we increment size after Current is called.
+ // If that throws an exception we don't want to do the increment.
+ items[_size] = en.Current;
+ _size++;
_version++;
}
}