[Mono-dev] [Patch] Generic Array.Sort

Ben Maurer bmaurer at ximian.com
Fri Aug 19 10:31:46 EDT 2005


> El vie, 19-08-2005 a las 01:08 -0400, Ben Maurer escribió:
>> > Hey,
>> >
>> > I've attached a patch containing the impl for the generic versions
>> of Array.Sort.
>>
>> 1) all the combsort stuff can probably go, IMHO -- With generics, we
>> will be able to inline stuff (it will take a bit of jit optimization
>> though -- we basically need to do inlining).
>
> Currently we use combsort with simple types, which doesn't need to use
> the CompareTo methods, since they have associated runtime instructions,
> as far as I know.
>
> Second, if inlining could help us in this scenario, can it do it right
> now? If that's not the case, we could keep these combsort methods and
> remove them when we are ready.

No, we can't. Also, to make this work we'd need to have a version of the
function with Comparer<T>.Default explicitly taken in the method (so that
we could inline there). However, the difference between the combsort and
the normal code path should be much smaller with generics. Feel free to do
a benchmark.

If we really wanted performance, we could do an icall here. The libc qsort
is hyper-optimized. IMHO, there is no way we could compete, especially for
large arrays. Feel free to benchmark and prove me wrong though.

-- Ben





More information about the Mono-devel-list mailing list