Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ public override T[] Rent(int minimumLength)
ArgumentOutOfRangeException.ThrowIfNegative(minimumLength);
}

buffer = GC.AllocateUninitializedArray<T>(minimumLength);
// For large arrays, we prefer to avoid the zero-initialization costs. However, as the resulting
// arrays could end up containing arbitrary bit patterns, we only allow this for types for which
// every possible bit pattern is valid.
buffer = typeof(T).IsPrimitive && typeof(T) != typeof(bool) ?
GC.AllocateUninitializedArray<T>(minimumLength) :
new T[minimumLength];

if (log.IsEnabled())
{
int bufferId = buffer.GetHashCode();
Expand Down
Loading