[Mono-dev] Possible QuickSort optimizations for Array.Sort()
Robert Jordan
robertj at gmx.net
Wed Apr 6 10:40:57 EDT 2011
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.
Fields marked with the "readonly" modifier are not inlined
because they are still normal fields.
pros: no versioning issues.
cons: slow.
Robert
More information about the Mono-devel-list
mailing list