Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a2442bd

Browse files
Zhukov Maximjkotas
authored andcommitted
Rename the method FloorLog2 to be more clear & fix spelling (#25335) (#15349)
1 parent 2d2cad8 commit a2442bd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/mscorlib/src/System/Array.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@ private void IntrospectiveSort(int left, int length)
19151915

19161916
try
19171917
{
1918-
IntroSort(left, length + left - 1, 2 * IntrospectiveSortUtilities.FloorLog2(keys.Length));
1918+
IntroSort(left, length + left - 1, 2 * IntrospectiveSortUtilities.FloorLog2PlusOne(keys.Length));
19191919
}
19201920
catch (IndexOutOfRangeException)
19211921
{
@@ -2121,7 +2121,7 @@ private void IntrospectiveSort(int left, int length)
21212121

21222122
try
21232123
{
2124-
IntroSort(left, length + left - 1, 2 * IntrospectiveSortUtilities.FloorLog2(keys.Length));
2124+
IntroSort(left, length + left - 1, 2 * IntrospectiveSortUtilities.FloorLog2PlusOne(keys.Length));
21252125
}
21262126
catch (IndexOutOfRangeException)
21272127
{

src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)