Commit Graph
207 Commits
Author SHA1 Message Date
Marek Safar fcb3c36009 [corlib] Array qsort without head allocation. Fixes #20922 2014-06-27 12:44:59 +02:00
Marek Safar 6169424b4c [corlib] Optimize EqualityComparer for common value types. Fixes #18400 2014-03-19 23:11:00 +01:00
Zoltan Varga 490ca4b751 Revert parts of 6769a30f4, it disabled the hand-specialized sort methods in the non-aot case instead of the aot case. 2014-03-04 18:41:42 -05:00
Marek Safar b90fc130ff [corlib] Allow to use custom comparer when sorting null values. 2014-02-03 20:27:58 +01:00
Marek Safar e679803c89 [corlib] Clean up array binary search argument checks 2014-02-03 18:36:24 +01:00
Marek Safar 27b2190c88 [corlib] Throw correct exception when array::copy elements don't match 2014-02-03 16:13:49 +01:00
Marek Safar c6989ab9f9 Unify Array/List FindIndex/FindLastIndex handling and argument checking. Fixes #14632 2013-09-13 14:51:08 +02:00
Zoltan Varga 013a38cfba Implement MethodMirror.MakeGenericMethod (). 2013-06-04 08:01:32 +02:00
Rodrigo Kumpera 4189fe3f95 Fast path Array::Resize with small arrays. 2013-03-25 10:42:01 -04:00
Rodrigo Kumpera 1b92a4148c Since MOBILE implies NET_4_* now, take this into account and simplify our ifdefs. 2013-02-11 18:42:18 -05:00
Rodrigo Kumpera b96d05dac3 Kill the MOONLIGHT define in corlib. 2013-02-11 16:03:28 -05:00
Zoltan Varga b8cae9d56a Make arrays implement IReadOnlyList<T> and IReadOnlyCollection<T> in net 4.5. Bump corlib version. Fixes #8934. 2013-01-05 02:36:32 +01:00
Marek Safar 83f76846a0 Add argument name to ArgumentOutOfRangeException 2013-01-02 18:19:28 +01:00
Zoltan Varga b373bf0cfb Fix a regression introduced by e14ff38a54. Fixes #8904. 2012-12-16 21:39:31 +01:00
Rodrigo Kumpera df224238c4 We must locally cache array since it can shrink from the outside and cause FastCopy to corrupt the heap. 2012-12-14 21:16:48 -05:00
Zoltan Varga d1bf04d303 Call the specialized SortImpl<T> implementation from Sort<T>. 2012-12-04 19:28:09 +01:00
Zoltan Varga 6769a30f4a Avoid using hand-specialized qsort<K,T> instantiations in SortImpl<TKey,TValue> when using full-aot, as it leads to a code blowup. Inline swap methods. 2012-12-04 19:15:59 +01:00
Rodrigo Kumpera 2c8c93b378 Remove SRE from Full AOT builds. 2012-11-06 18:18:14 -05:00
Marek Safar 8e63a3be52 Better reference type check 2012-10-08 13:08:49 +01:00
Marek Safar e14ff38a54 Spped up array reverse 2012-10-02 13:20:46 +01:00
Marek Safar b8b042389f Fix array IStructuralEquatable.GetHashCode to use provided comparer. 2012-10-02 13:20:45 +01:00
Rodrigo Kumpera a55c6e0bc7 Implement Array.UnsafeLoad and Array.UnsafeStore. Both functions ignores bounds check when possible.
* Array.cs: Add UnsafeLoad and UnsafeStore functions that don't perform bounds check.
	The JIT will generate, when possible, direct a load/store. Right now the only case we can't
	handle are stores to reference arrays.

	Reference arrays are covariant on their element type which means that we must perform a runtime
	type check on stores to preserve type safety. Since the type check is usually must more expensive
	than the bounds check we simply ignore this for now.

	The reasoning behind this decision was that given our initial target are corlib's collections and
	they are too covariant to their element types they do need too a runtime type check on stores to ensure
	correctness.
2012-10-01 14:28:04 -04:00
Jeffrey Stedfast 876615e258 [corlib] Fixed performance regression in qsort() functions
Many thanks to Martin Potter who both discovered this performance
regression, providing a test case, and proposing this patch/solution.

If most of the keys have identical values as the pivot, the partitions
would become largely lopsided resulting in a worst-case scenario runtime.

We can avoid this worst-case scenario by keeping the partitions better
balanced. To do this, we can modify the "closing-in of the walls" loops
to allow items with keys identical to the pivot to be swapped to the
higher-order partition (the previous implementation would greedily
keep them in the low-order partition).

As an added bonus, this also allows us to remove the code that was needed
to keep track of the pivot index.
2012-08-07 19:06:50 -04:00
Jeffrey Stedfast 71bb64df71 [corlib] Fallback to Insertion Sort in the non-generic qsort()
Many thanks to Martin Potter <[email protected]> for taking
the time to implement this, crossing it off of the long TODO list!
2012-08-07 12:17:16 -04:00
Jeffrey Stedfast 9c9e2c6b1d [corlib] Make all qsort() implementations completely non-recursive
This is a better fix for StackOverflowExceptions on large data sets.
2012-08-07 12:03:24 -04:00
Jeffrey Stedfast 050eba485a [corlib] Modified Array.qsort*() to inline sorting of the larger partition
This prevents potential StackOverflowExceptions on really large data sets.

Partial fix for bug #6406
2012-08-06 16:47:58 -04:00
Marek Safar e0c751d31d Fix array binary comparer values ordering. Fixes #5409 2012-05-30 14:30:48 +01:00
Zoltan Varga 4b51bbf829 Add hand-specialized versions of the various Array.Sort () methods for the items=null case to speed it up, and to avoid the generation of strange methods like qsort<double, System.Reflection.CustomAttributeTypedArgument> () when using full-aot. 2012-03-15 03:00:59 +01:00
Marek Safar a1d0f2206f Add tests for InternalArray::GetIndex 2011-11-30 14:17:01 +00:00
Marek Safar 69b05e2137 Fix Array::Contains for null items via ICollection<T>. Fixes #2260 2011-11-30 13:48:16 +00:00
Zoltan Varga 13d2cbd195 Fix sorting of ulong[] arrays among others when using the non-generic Sort() overloads. 2011-07-01 01:01:15 +02:00
Jeffrey Stedfast d97cdb0c12 Optimized QuickSort routines a bit 2011-04-12 11:48:43 -04:00
Marek Safar 29fc730f2a Better error message for fixed size collections 2011-03-29 17:35:22 +01:00
Geoff Norton 16d4fd790b Further .NET 4.0 ification of the mobile profile 2011-01-25 20:10:54 -05:00
Zoltan Varga 8e755d3501 Fix another regression in the Array.Sort () methods, allow keys and items to be of different length. Fixes #648828. 2010-10-23 16:47:30 +02:00
Marek Safar 64e23ecf50 Speed up Array.Resize 2010-08-12 15:33:24 +01:00
Miguel de Icaza 19e2aec347 2010-07-21 Miguel de Icaza <[email protected]>
* Array.cs: Fixes a couple of other cases where we were missing
	the handling for null values, fixes a broken case of null
	handling. 


svn path=/trunk/mcs/; revision=160699
2010-07-21 21:47:44 +00:00
Miguel de Icaza 5685900d9e 2010-07-20 Miguel de Icaza <[email protected]>
* Array.cs: fast path for the case where the pivot is null;
	Fixes the crash on the build.

svn path=/trunk/mcs/; revision=160636
2010-07-20 21:33:20 +00:00
Miguel de Icaza 68622b622a 2010-07-17 Miguel de Icaza <[email protected]>
* Array.cs: Fix for bug #622101, this reverts portions of the
	broken patch that was introduced as part of the fix for #351638
	which was mostly a set of optimizations, but some were just
	wrong. 



svn path=/trunk/mcs/; revision=160527
2010-07-17 20:38:39 +00:00
Zoltan Varga f2c97b7c5f 2010-06-25 Zoltan Varga <[email protected]>
* Array.cs (SortImpl): Fix the 'fast path' which used 'as' to cast objects so
	it never sorted the items array if it was not a object[]. Fixes #616416.

svn path=/trunk/mcs/; revision=159551
2010-06-25 17:33:23 +00:00
Jb Evain e8fb1605dc 2010-06-21 Jb Evain <[email protected]>
* Array.cs: implement IStructuralComparable and IStructuralEquatable
	on moonlight as well.


svn path=/trunk/mcs/; revision=159248
2010-06-21 12:23:47 +00:00
Marek Safar b5aa5ab807 2010-04-06 Marek Safar <[email protected]>
* Array.cs: Don't make read-only collection read-only.


svn path=/trunk/mcs/; revision=154834
2010-04-06 09:55:46 +00:00
Zoltan Varga 9a8a1b9161 2010-03-01 Zoltan Varga <[email protected]>
* Array.cs (CreateArray): Disallow creation of arrays of unfinished types.

svn path=/trunk/mcs/; revision=152742
2010-03-01 19:52:06 +00:00
Gonzalo Paniagua Javier 694e702d89 2010-01-25 Gonzalo Paniagua Javier <[email protected]>
* Array.cs: updates to the API from beta2.
	* _AppDomain.cs: no GetLifeTimeService() in 4.0


svn path=/trunk/mcs/; revision=150155
2010-01-25 21:06:42 +00:00
Rodrigo Kumpera 6b69482d58 2010-01-15 Rodrigo Kumpera <[email protected]>
* Array.cs: Implement IStructuralComparer.

2010-01-15 Rodrigo Kumpera  <[email protected]>

	* ArrayTest.cs: Tests for IStructuralComparer::CompareTo.

svn path=/trunk/mcs/; revision=149647
2010-01-15 20:50:45 +00:00
Zoltan Varga 8f0107a2b9 2010-01-03 Zoltan Varga <[email protected]>
* Array.cs: Fix ArrayReadOnlyList.CopyTo. Fixes #564095.

svn path=/trunk/mcs/; revision=148974
2010-01-03 14:10:16 +00:00
Marek Safar 1fda301a35 Fixes build with obsolete runtime
svn path=/trunk/mcs/; revision=148460
2009-12-15 11:18:14 +00:00
Marek Safar 4f021c3547 2009-12-15 Marek Safar <[email protected]>
* Array.cs: Optimize sort operations on all primitive types.


svn path=/trunk/mcs/; revision=148450
2009-12-15 09:43:47 +00:00
Jb Evain 1eb42efe79 2009-11-24 Jb Evain <[email protected]>
* Array.cs: use ContainsGenericParameters instead of
	IsGenericTypeDefinition as it catches more cases.


svn path=/trunk/mcs/; revision=146834
2009-11-24 15:24:28 +00:00
Jb Evain b52b44583d in System:
2009-11-24  Jb Evain  <[email protected]>

	* Array.cs (IList.this[int]): prevent the use of the IList indexer 
	when dealing with a multi dimensional array.

in Test/System:
2009-11-24  Jb Evain  <[email protected]>

	* ArrayTest.cs: test that we don't allow the use of the IList indexer
	on a multi dimensional array.

svn path=/trunk/mcs/; revision=146831
2009-11-24 15:01:31 +00:00