[Mono-dev] Possible QuickSort optimizations for Array.Sort()

Jeffrey Stedfast fejj at novell.com
Wed Apr 6 11:03:07 EDT 2011


On 04/06/2011 10:40 AM, Robert Jordan wrote:
> Hi,
>
> On 06.04.2011 15:48, Jeffrey Stedfast wrote:
>>> static readonly int INSERTIONSORT_THRESHOLD = 7;
>>>
>>> Why not to used const int ?
>> I never learned when to use const vs static/readonly in C# :-(
> Consts will be expanded inline by the compiler.
>
> pros: fast
> cons: versioning trouble when the const is public and it is
> consumed by another assembly.

Aha, thanks. So yea, in this case it makes sense to use const.

Jeff



More information about the Mono-devel-list mailing list