@@ -32,11 +32,11 @@ internal interface IArraySortHelper<TKey>
3232 internal static class IntrospectiveSortUtilities
3333 {
3434 // This is the threshold where Introspective sort switches to Insertion sort.
35- // Imperically , 16 seems to speed up most cases without slowing down others, at least for integers.
35+ // Empirically , 16 seems to speed up most cases without slowing down others, at least for integers.
3636 // Large value types may benefit from a smaller number.
3737 internal const int IntrosortSizeThreshold = 16 ;
3838
39- internal static int FloorLog2 ( int n )
39+ internal static int FloorLog2PlusOne ( int n )
4040 {
4141 int result = 0 ;
4242 while ( n >= 1 )
@@ -213,7 +213,7 @@ internal static void IntrospectiveSort(T[] keys, int left, int length, Compariso
213213 if ( length < 2 )
214214 return ;
215215
216- IntroSort ( keys , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2 ( keys . Length ) , comparer ) ;
216+ IntroSort ( keys , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2PlusOne ( keys . Length ) , comparer ) ;
217217 }
218218
219219 private static void IntroSort ( T [ ] keys , int lo , int hi , int depthLimit , Comparison < T > comparer )
@@ -500,7 +500,7 @@ internal static void IntrospectiveSort(T[] keys, int left, int length)
500500 if ( length < 2 )
501501 return ;
502502
503- IntroSort ( keys , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2 ( keys . Length ) ) ;
503+ IntroSort ( keys , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2PlusOne ( keys . Length ) ) ;
504504 }
505505
506506 private static void IntroSort ( T [ ] keys , int lo , int hi , int depthLimit )
@@ -778,7 +778,7 @@ internal static void IntrospectiveSort(TKey[] keys, TValue[] values, int left, i
778778 if ( length < 2 )
779779 return ;
780780
781- IntroSort ( keys , values , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2 ( keys . Length ) , comparer ) ;
781+ IntroSort ( keys , values , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2PlusOne ( keys . Length ) , comparer ) ;
782782 }
783783
784784 private static void IntroSort ( TKey [ ] keys , TValue [ ] values , int lo , int hi , int depthLimit , IComparer < TKey > comparer )
@@ -1027,7 +1027,7 @@ internal static void IntrospectiveSort(TKey[] keys, TValue[] values, int left, i
10271027 if ( length < 2 )
10281028 return ;
10291029
1030- IntroSort ( keys , values , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2 ( keys . Length ) ) ;
1030+ IntroSort ( keys , values , left , length + left - 1 , 2 * IntrospectiveSortUtilities . FloorLog2PlusOne ( keys . Length ) ) ;
10311031 }
10321032
10331033 private static void IntroSort ( TKey [ ] keys , TValue [ ] values , int lo , int hi , int depthLimit )
0 commit comments