зеркало из https://github.com/dotnet/razor.git
A bit of clean up
This commit is contained in:
Родитель
0e33edc196
Коммит
7508c52c91
|
@ -456,19 +456,14 @@ internal static class EnumerableExtensions
|
|||
}
|
||||
|
||||
var length = newArray.Length;
|
||||
|
||||
using var keys = SortKey<TKey>.GetPooledArray(minimumLength: length);
|
||||
|
||||
if (sortHelper.ComputeKeys(newArray.AsSpan(), keySelector, keys.Span))
|
||||
if (!sortHelper.ComputeKeys(newArray.AsSpan(), keySelector, keys.Span))
|
||||
{
|
||||
// No need to sort - keys are already ordered.
|
||||
return ImmutableCollectionsMarshal.AsImmutableArray(newArray);
|
||||
// The keys are not ordered, so we need to sort the array.
|
||||
Array.Sort(keys.Array, newArray, 0, length, sortHelper.GetOrCreateComparer());
|
||||
}
|
||||
|
||||
var comparer = sortHelper.GetOrCreateComparer();
|
||||
|
||||
Array.Sort(keys.Array, newArray, 0, length, comparer);
|
||||
|
||||
return ImmutableCollectionsMarshal.AsImmutableArray(newArray);
|
||||
}
|
||||
|
||||
|
|
|
@ -387,16 +387,14 @@ internal static partial class ImmutableArrayExtensions
|
|||
|
||||
if (sortHelper.ComputeKeys(items, keySelector, keys.Span))
|
||||
{
|
||||
// No need to sort - keys are already ordered.
|
||||
// The keys are already ordered, so we don't need to create a new array and sort it.
|
||||
return array;
|
||||
}
|
||||
|
||||
var newArray = new TElement[length];
|
||||
items.CopyTo(newArray);
|
||||
|
||||
var comparer = sortHelper.GetOrCreateComparer();
|
||||
|
||||
Array.Sort(keys.Array, newArray, 0, length, comparer);
|
||||
Array.Sort(keys.Array, newArray, 0, length, sortHelper.GetOrCreateComparer());
|
||||
|
||||
return ImmutableCollectionsMarshal.AsImmutableArray(newArray);
|
||||
}
|
||||
|
|
|
@ -173,17 +173,12 @@ internal static partial class ImmutableArrayExtensions
|
|||
|
||||
using var keys = SortKey<TKey>.GetPooledArray(minimumLength: length);
|
||||
|
||||
if (sortHelper.ComputeKeys(items, keySelector, keys.Span))
|
||||
if (!sortHelper.ComputeKeys(items, keySelector, keys.Span))
|
||||
{
|
||||
// No need to sort - keys are already ordered.
|
||||
return array;
|
||||
// The keys are not ordered, so we need to sort the array.
|
||||
Array.Sort(keys.Array, innerArray, 0, length, sortHelper.GetOrCreateComparer());
|
||||
}
|
||||
|
||||
var comparer = sortHelper.GetOrCreateComparer();
|
||||
|
||||
Array.Sort(keys.Array, innerArray, 0, length, comparer);
|
||||
|
||||
// Because we modified the inner array, we can just return array.
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1314,14 +1314,13 @@ internal static class ReadOnlyListExtensions
|
|||
|
||||
if (sortHelper.ComputeKeys(list, keySelector, keys.Span))
|
||||
{
|
||||
// No need to sort - keys are already ordered.
|
||||
// The keys are already ordered, so we don't need to create a new array and sort it.
|
||||
return ImmutableCollectionsMarshal.AsImmutableArray(list.ToArray());
|
||||
}
|
||||
|
||||
var newArray = list.ToArray();
|
||||
var comparer = sortHelper.GetOrCreateComparer();
|
||||
|
||||
Array.Sort(keys.Array, newArray, 0, length, comparer);
|
||||
Array.Sort(keys.Array, newArray, 0, length, sortHelper.GetOrCreateComparer());
|
||||
|
||||
return ImmutableCollectionsMarshal.AsImmutableArray(newArray);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче