30 lines
616 B
C#
Raw Normal View History

2025-10-22 21:39:13 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
#nullable enable
using System.Runtime.CompilerServices;
namespace MemoryPack.Internal {
internal static class MathEx
{
const int ArrayMexLength = 0x7FFFFFC7;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int NewArrayCapacity(int size)
{
var newSize = unchecked(size * 2);
if ((uint)newSize > ArrayMexLength)
{
newSize = ArrayMexLength;
}
return newSize;
}
}
}