diff options
author | Rodrigo Kumpera <kumpera@gmail.com> | 2013-03-25 18:25:44 +0400 |
---|---|---|
committer | Rodrigo Kumpera <kumpera@gmail.com> | 2013-03-25 18:42:01 +0400 |
commit | 4189fe3f95155ee79f2ac0db53ab14e2cf26e45e (patch) | |
tree | 54e010c1fdd82567224cc85d46eb1c58dce2eb06 /mcs | |
parent | 694f00b66fe642268f5c38443071d0acc08f1b44 (diff) |
Fast path Array::Resize with small arrays.
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/corlib/System/Array.cs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mcs/class/corlib/System/Array.cs b/mcs/class/corlib/System/Array.cs index db82bdcf924..2f90fbd131b 100644 --- a/mcs/class/corlib/System/Array.cs +++ b/mcs/class/corlib/System/Array.cs @@ -2808,8 +2808,14 @@ namespace System return; T [] a = new T [newSize]; - if (length != 0) - FastCopy (arr, 0, a, 0, Math.Min (newSize, length)); + int tocopy = Math.Min (newSize, length); + + if (tocopy < 9) { + for (int i = 0; i < tocopy; ++i) + UnsafeStore (a, i, UnsafeLoad (arr, i)); + } else { + FastCopy (arr, 0, a, 0, tocopy); + } array = a; } |